Skip to content

Improve/archived object map aws error#3147

Open
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:improve/archived-object-mapAWSError
Open

Improve/archived object map aws error#3147
AdaAibaby wants to merge 2 commits into
e2b-dev:mainfrom
AdaAibaby:improve/archived-object-mapAWSError

Conversation

@AdaAibaby

Copy link
Copy Markdown
Contributor

refactor: extract mapAWSError helper to reduce duplication

Consolidate the duplicated AWS error → sentinel mapping across WriteTo, OpenRangeReader, and Size into a single mapAWSError() helper function.

This also fixes an inconsistency where Size() checked types.NotFound but the other two methods did not.

Changes: 1 file, +23 -34 (net reduction of 11 lines)

gaomingxing and others added 2 commits June 29, 2026 19:23
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
Consolidate AWS error-to-sentinel mapping into a single mapAWSError()
function, replacing duplicated InvalidObjectState/NoSuchKey/NotFound
checks across WriteTo, OpenRangeReader, and Size methods.

This also fixes an inconsistency where Size() checked types.NotFound
but WriteTo() and OpenRangeReader() did not.

@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 support for identifying and handling archived storage objects that cannot be directly read. It defines a new sentinel error ErrObjectArchived, maps AWS S3 InvalidObjectState errors to this sentinel, and updates the orchestrator's sandbox creation logic to return a failed precondition error when encountering archived files. There are no review comments, and we have no feedback to provide.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fd994b7b92

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +258 to +261
if errors.Is(err, storage.ErrObjectArchived) {
telemetry.ReportError(ctx, "sandbox files archived", err, telemetry.WithSandboxID(req.GetSandbox().GetSandboxId()))

return nil, status.Errorf(codes.FailedPrecondition, "sandbox files for '%s' are archived and not directly accessible, please rebuild the template", req.GetSandbox().GetSandboxId())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle archived metadata before resuming

When the archived object is the template metadata blob, template.Metadata() above returns the ErrObjectArchived produced by awsObject.WriteTo, but this new check only runs after RebootSandbox/ResumeSandbox return an error. That path exits earlier with failed to read template metadata instead of the new FailedPrecondition rebuild response, so archived templates whose metadata object is in GLACIER still surface as a generic Create failure.

Useful? React with 👍 / 👎.

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.

3 participants