Repository navigation
fix(s3): resolve task completions on HeadObject so HEAD matches GET (#457) - #460
Merged
Merged
Conversation
…457) getObject consults resolveTaskCompletion when no real object is staged at tasks/<task_id>/completion.json (#360). headObject had no equivalent hook, so HEAD returned NoSuchKey for a key GET served with a 200 and a full body. Real S3 never contradicts itself about whether an object exists. Reproduced before fixing: GET → 200 with a 120-byte body and an ETag, HEAD → 404 on the identical key. The practical failure is that `aws s3 cp` cannot read a synthesized record at all. The CLI HEADs before it GETs, so it fails on the 404 and never reaches the working GET — and that is the exact command spawn prints for users. An SDK HeadObject existence poll breaks in the worse direction: absence reads as "still running", so a wait loop spins forever instead of failing visibly. headObject now calls the same resolver, discarding the body. The resolver returns a fully-populated S3Object, so Content-Length, ETag, Content-Type and Last-Modified match what GET reports with no new synthesis logic, and the ended_at clock gate applies identically — a HEAD before the simulated completion time is still the 404 a poll loop depends on. The versionID == "" guard and the real-object-wins precedence mirror getObject: a synthesized record has no version history, so answering for a named version would invent one. Tests assert HEAD and GET together rather than either alone, since the defect was precisely one verb's view of the resolver drifting from the other's. The matrix covers nominal success, a seeded failure, the clock gate, and a real staged object, plus HEAD-specific coverage for ranges, conditionals, non-matching keys, and an explicit versionId. Mutation-tested: reverting the fix fails four tests; dropping the versionID guard fails the versioned case; moving delete-marker handling out of the else fails the existing TestS3_GetHeadObject_DeleteMarker. Documents the task-completion resolver in docs/services.md for the first time, including the reporter's point that ListObjectsV2 not enumerating synthesized records is correct and deliberate — a keyed read works because the caller names the task, while a list is unkeyed and substrate cannot enumerate the task IDs a consumer might ask about.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Closes #457.
The defect
getObjectconsultsresolveTaskCompletionwhen no real object is staged attasks/<task_id>/completion.json(#360).headObjecthad no equivalent hook, so thetwo verbs disagreed about whether the key exists — something real S3 never does.
Reproduced before fixing:
aws s3 cpcould not read a synthesized record at all. The CLI HEADs before itGETs, fails on the 404, and never reaches the working GET — and that is the exact
command spawn prints for users.
An SDK
HeadObjectpoll broke in the worse direction. Absence reads as stillrunning, so a wait loop spins forever rather than failing visibly. That is the
inverse of the polarity this batch has mostly been closing: not success where AWS
fails, but absence where substrate's own GET reports presence.
The fix
headObjectcalls the same resolver, discarding the body:The resolver returns a fully-populated
S3Object, soContent-Length,ETag,Content-TypeandLast-Modifiedmatch whatGETreports with no new synthesislogic. The
versionID == ""guard and the real-object-wins precedence mirrorgetObject, and the delete-marker branch moves into theelsewhere it belongs — asynthesized record cannot be a delete marker.
The clock gate applies identically, which the issue specifically asked to have
confirmed: a HEAD before the simulated
ended_atis still the404that a poll loopdepends on to keep polling. Asserted directly, not assumed.
Tests
Tests assert HEAD and GET together rather than either in isolation, since the
defect was precisely one verb's view of the resolver drifting from the other's — a
test exercising one verb could never have caught it.
TestSpawn_TaskCompletion_HeadMatchesGetruns the resolver's whole behavior matrixthrough both verbs: nominal success, a seeded failure, the clock-gated
not-yet-complete case, and a real staged object. Each asserts the two status codes
agree, and on a 200 that every header a HEAD exists to report matches what GET
returns — including
Content-Lengthagainst the actual byte count, which is whataws s3 cpsizes its download from.Plus HEAD-specific coverage: ranges (satisfiable and unsatisfiable), conditionals
(
If-None-Match→ 304, non-matchingIf-Match→ 412, which is what makes a cheap"has it changed?" poll work), non-matching keys still 404, and an explicit
versionIdnot resolving.Mutation-tested:
versionID == ""guardelseTestS3_GetHeadObject_DeleteMarkerfailsDocs
The task-completion resolver was undocumented entirely — no mention of the key
shape, the seeding endpoints, or the clock gate anywhere in
docs/. Added a### Task-completion recordssection covering all of it, plus the HEAD/GET agreementcontract.
It also records the reporter's point about
ListObjectsV2: not enumeratingsynthesized records is correct and deliberate, not an oversight. A keyed read
works because the caller names the task, so the resolver has something to answer
about; a list is unkeyed and substrate cannot enumerate the set of task IDs a
consumer might ask about, so a list that invented entries would be a wrong answer
rather than a more complete one.
Not addressed here
The issue's closing note that
go installed builds report"version":"dev"on/healthis real but separate — it's #402's immutable-tag caveat applying togo install, since the-Xldflag is only set by the release build. Left out ofscope deliberately rather than silently.
Verification
gofmt -l·go build ./...·go vet ./...·golangci-lint run ./...(0 issues) ·make test(race) ·make docs-reference-check docs-versions— all clean.