Skip to content

fix: handle InvalidObjectState error for archived S3 objects#3138

Open
gaomingxing wants to merge 1 commit into
e2b-dev:mainfrom
gaomingxing:fix/handle-archived-object-state
Open

fix: handle InvalidObjectState error for archived S3 objects#3138
gaomingxing wants to merge 1 commit into
e2b-dev:mainfrom
gaomingxing:fix/handle-archived-object-state

Conversation

@gaomingxing

Copy link
Copy Markdown

Summary

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 unhandled, causing sandbox creation to fail with a generic "Internal" gRPC error.

Changes

packages/shared/pkg/storage/storage.go

  • Added ErrObjectArchived sentinel error for archived/inaccessible objects

packages/shared/pkg/storage/storage_aws.go

  • WriteTo(): handle types.InvalidObjectStateErrObjectArchived
  • OpenRangeReader(): handle types.InvalidObjectStateErrObjectArchived
  • Size(): handle types.InvalidObjectStateErrObjectArchived

packages/shared/pkg/storage/metrics.go

  • Added OutcomeArchived constant for metrics tracking
  • Outcome() function now maps ErrObjectArchived to the "archived" outcome

packages/orchestrator/pkg/server/sandboxes.go

  • Create(): check for ErrObjectArchived and return FailedPrecondition with a clear message telling users to rebuild the template

Testing

  • Verified compilation of both shared/pkg/storage and orchestrator/pkg/server packages
  • The InvalidObjectState error 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 in GLACIER, ARCHIVE, or similar storage classes

Closes #3137

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandbox creation fails with generic error when template files are in archived storage class

1 participant