Repository navigation
Conversation
…e AWS error mapping
Three awsObject read methods each mapped AWS S3 errors inline, and they
disagreed: Size checked both NoSuchKey and NotFound, while WriteTo and
OpenRangeReader checked only NoSuchKey. HeadObject (Size) surfaces NotFound but
GetObject (WriteTo/OpenRangeReader) surfaces NoSuchKey, so a genuinely-missing
object was reported as ErrObjectNotExist from one path and as a raw AWS error
from another.
In addition, an object lifecycle-transitioned to an archived storage class
(GLACIER/DEEP_ARCHIVE) fails GetObject with InvalidObjectState, which no path
mapped: a resume/create of such a template surfaced an opaque S3 error (a 500),
with no signal that the fix is to rebuild the template.
Consolidate the mapping into mapAWSError: NoSuchKey and NotFound -> the existing
ErrObjectNotExist; InvalidObjectState -> a new ErrObjectArchived sentinel;
anything else -> nil so the caller keeps its own operation-specific context (in
particular OpenRangeReader keeps its "failed to create S3 range reader for %q"
wrapper for unmapped errors). All three methods now go through it, fixing the
NotFound inconsistency.
The orchestrator Create handler maps ErrObjectArchived to FailedPrecondition
with an actionable message ("archived and not directly accessible, please
rebuild the template"), alongside the existing not-found branch; storage metrics
gain an "archived" outcome.
Rebased onto current main (methods now use errors.AsType, a Go 1.26 stdlib
generic). Follows the review on the original e2b-dev#3147 by preserving per-operation
error context on unmapped errors, and supersedes e2b-dev#3138 (the narrower
InvalidObjectState-only change). Adds TestMapAWSError.
Closes e2b-dev#3138.
AdaAibaby
requested review from
ValentaTomas,
dobrac and
jakubno
as code owners
October 23, 2026 07:06
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased follow-up consolidating #3147 and #3138 (both closed) against current
main. Two real issues, both still present.1. Inconsistent "object missing" mapping
The three
awsObjectread methods each mapped S3 errors inline and disagreed:Size(HeadObject) checked bothNoSuchKeyandNotFound, whileWriteTo/OpenRangeReader(GetObject) checked onlyNoSuchKey. So a genuinely-missing object wasErrObjectNotExistfrom one path and a raw AWS error from another.2. Archived objects surface an opaque error
An object lifecycle-transitioned to an archived storage class (GLACIER / DEEP_ARCHIVE) fails GetObject with
InvalidObjectState, which no path mapped. A resume/create of such a template surfaced an opaque S3 error (a 500) with no hint that the fix is to rebuild the template.Fix
Consolidate into
mapAWSError:NoSuchKey,NotFound→ existingErrObjectNotExistInvalidObjectState→ newErrObjectArchivednil, so the caller keeps its own operation-specific contextAll three methods now go through it (fixing the
NotFoundinconsistency), andOpenRangeReaderkeeps its"failed to create S3 range reader for %q"wrapper for unmapped errors — per the review on #3147.The orchestrator
Createhandler mapsErrObjectArchivedtoFailedPreconditionwith an actionable message ("archived and not directly accessible, please rebuild the template"), beside the existing not-found branch; storage metrics gain anarchivedoutcome.Notes
errors.AsType(Go 1.26 stdlib generic), matching currentmain.InvalidObjectStateerror for archived S3 objects #3138 (InvalidObjectState-only) and the earlier Improve/archived object map aws error #3147 (which dropped OpenRangeReader's context — restored here).TestMapAWSError(NoSuchKey/NotFound/InvalidObjectState, wrapped variants, unknown → nil).go build ./...andgo vetpass.Closes #3138.