fix: handle InvalidObjectState error for archived S3 objects#3138
fix: handle InvalidObjectState error for archived S3 objects#3138gaomingxing wants to merge 1 commit into
InvalidObjectState error for archived S3 objects#3138Conversation
When objects are transitioned to archived storage classes (e.g. GLACIER, ARCHIVE_FR, COLD_ARCHIVE) via lifecycle rules, S3-compatible backends return an InvalidObjectState error on GetObject/HeadObject instead of the usual NoSuchKey. Previously this was not handled, causing sandbox creation to fail with a generic 'Internal' gRPC error. Now: - Added ErrObjectArchived sentinel error in storage package - AWS storage provider maps InvalidObjectState to ErrObjectArchived in WriteTo, OpenRangeReader, and Size methods - Orchestrator returns a clear FailedPrecondition error telling users to rebuild the template when sandbox files are archived - Metrics track archived objects as a distinct 'archived' outcome
There was a problem hiding this comment.
Code Review
This pull request introduces handling for archived storage objects by defining a new error ErrObjectArchived and its corresponding metric outcome OutcomeArchived. It updates AWS storage operations to detect types.InvalidObjectState errors and wrap them as ErrObjectArchived, and updates the orchestrator's sandbox creation logic to handle this error by reporting it to telemetry and returning a failed precondition status. I have no feedback to provide as there are no review comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
When objects are transitioned to archived storage classes (e.g.
GLACIER,ARCHIVE_FR,COLD_ARCHIVE) via lifecycle rules, S3-compatible backends return anInvalidObjectStateerror onGetObject/HeadObjectinstead of the usualNoSuchKey. Previously this was unhandled, causing sandbox creation to fail with a generic "Internal" gRPC error.Changes
packages/shared/pkg/storage/storage.goErrObjectArchivedsentinel error for archived/inaccessible objectspackages/shared/pkg/storage/storage_aws.goWriteTo(): handletypes.InvalidObjectState→ErrObjectArchivedOpenRangeReader(): handletypes.InvalidObjectState→ErrObjectArchivedSize(): handletypes.InvalidObjectState→ErrObjectArchivedpackages/shared/pkg/storage/metrics.goOutcomeArchivedconstant for metrics trackingOutcome()function now mapsErrObjectArchivedto the"archived"outcomepackages/orchestrator/pkg/server/sandboxes.goCreate(): check forErrObjectArchivedand returnFailedPreconditionwith a clear message telling users to rebuild the templateTesting
shared/pkg/storageandorchestrator/pkg/serverpackagesInvalidObjectStateerror type is part of the AWS SDK v2 (github.com/aws/aws-sdk-go-v2/service/s3/types) and is returned when attempting to read objects inGLACIER,ARCHIVE, or similar storage classesCloses #3137