Repository navigation
Description
Summary
getObject resolves a seedable task-completion when no real object exists at
tasks/<task_id>/completion.json (#360), but headObject has no equivalent
hook — it returns NoSuchKey for the same key. So HEAD and GET disagree about
whether the object exists, which real S3 never does.
The practical consequence is that aws s3 cp cannot read a synthesized
completion record at all, because the CLI HEADs before it GETs. That is the
exact command spawn prints for users:
Completion: s3://spawn-results-<acct>-<region>/tasks/<id>/completion.json
aws s3 cp s3://spawn-results-<acct>-<region>/tasks/<id>/completion.json -
Reproduction (v0.83.0, substrate server)
$ export AWS_ENDPOINT_URL=http://localhost:4566 AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test AWS_DEFAULT_REGION=us-east-1
$ B=spawn-results-123456789012-us-east-1
$ aws s3 mb s3://$B
# GET synthesizes the nominal completion — correct, as designed:
$ aws s3api get-object --bucket $B --key tasks/t1/completion.json /dev/stdout
{"task_id":"t1","exit_code":0,"state":"completed","started_at":"…","ended_at":"…"}
# HEAD on the very same key says it does not exist:
$ aws s3api head-object --bucket $B --key tasks/t1/completion.json
An error occurred (404) when calling the HeadObject operation: Not Found
# …so the documented user-facing command fails, never reaching the GET:
$ aws s3 cp s3://$B/tasks/t1/completion.json -
download failed: … An error occurred (404) when calling the HeadObject operation: Not FoundHolds identically for an explicitly seeded record:
$ curl -s -X POST localhost:4566/v1/spawn/task-completion -H 'Content-Type: application/json' \
-d '{"task_id":"s1","exit_code":7,"state":"failed","started_at":"…","ended_at":"…"}'
{"ok":true,"taskId":"s1"}
$ aws s3api head-object --bucket $B --key tasks/s1/completion.json
An error occurred (404) when calling the HeadObject operation: Not FoundA really staged object at the same key HEADs fine — confirming the gap is
specific to the synthesis path, not to HEAD generally.
Cause
emulator/s3_plugin.go — getObject (~line 617) calls the resolver when
data == nil:
if data == nil {
var handled bool
if versionID == "" {
obj, body, handled = p.resolveTaskCompletion(ctx, key)
}
if !handled {
return s3ErrorResponse("NoSuchKey", …, http.StatusNotFound), nil
}
}headObject (~line 692) has no counterpart:
if data == nil {
return s3ErrorResponse("NoSuchKey", …, http.StatusNotFound), nil
}Why it matters
This is the failure shape v0.80.0–v0.83.0 have been systematically closing, with
the polarity flipped: instead of substrate reporting success where AWS fails, it
reports absence where its own GET reports presence, so a consumer's
"is it done yet?" probe is wrong in the direction that looks like still running
— a poll loop that never terminates rather than a visible error.
Two consumer patterns hit it:
aws s3 cp/aws s3 sync— HEAD-then-GET. Cannot read the record at all.- SDK
HeadObjectexistence polling — a common way to wait for a completion
marker without paying for the body. spore-host's own
pipeline.CheckCompletionMarkerpolls a marker this way.
spore-host's engine-composition tests (miniwdl / airflow / snakemake) happen to
be unaffected, because spawn's fetchCompletion goes straight to
GetObject and treats NoSuchKey as "not finished". They pass for a reason
that is one refactor away from not holding.
Suggested fix
Give headObject the same resolver call, discarding the body — the resolver
already returns a fully-populated S3Object, so objectResponseHeaders(&obj)
should produce a consistent Content-Length/ETag/Content-Type with no new
synthesis logic:
if data == nil {
var handled bool
if versionID == "" {
obj, _, handled = p.resolveTaskCompletion(ctx, key)
}
if !handled {
return s3ErrorResponse("NoSuchKey", …, http.StatusNotFound), nil
}
} else { … }Worth confirming the clock/consistency gating (resolveTaskCompletion's
not-yet-complete case) behaves the same on HEAD as GET, so a HEAD before the
simulated completion time is a 404 exactly as the GET is.
Out of scope, deliberately
ListObjectsV2 also omits synthesized completions, and I'd argue that one is
correct as-is and should not be "fixed": HEAD is keyed — the caller names the
task, so the resolver can answer — whereas a list is unkeyed and substrate
cannot enumerate the set of task IDs a consumer might ask about. Noting it so the
asymmetry is a recorded decision rather than an oversight.
Environment
- substrate v0.83.0 (
go install …/cmd/[email protected]),substrate server - aws-cli v2, macOS
- Unrelated but noticed: this build's
/healthand/_localstack/infostill
report"version":"dev"— that's Released container images report version "dev" from /health and /_localstack/info #402's "published tags are immutable" caveat
applying togo installbuilds too, since the-Xldflag is only set by the
release build. Mentioning only so it isn't mistaken for a regression.
Activity
fix(s3): resolve task completions on HeadObject so HEAD matches GET (#…
scttfrdmn commentedon Aug 1, 2026
Fixed and merged in #460.
Reproduced exactly as filed before touching anything, which is worth recording because
the two responses are so far apart:
The suggested fix was right, including the
versionID == ""guard.headObjectnowcalls the same resolver and discards the body; because the resolver already returns a
fully-populated
S3Object,objectResponseHeadersproduces aContent-Length,ETag,Content-TypeandLast-Modifiedidentical to whatGETreports, with no new synthesislogic. The delete-marker branch moved into the
elsewhere it belongs — a synthesizedrecord cannot be a delete marker.
On the clock gate
You flagged this as worth confirming rather than assuming. Confirmed, and asserted
directly: a HEAD before the seeded
ended_atis a404, exactly as the GET is. Thatcase is in the table as
clock-gated, not yet complete, and it matters more than thepositive cases — a HEAD that answered
200early would report a task complete that GETstill reports as absent, which is the same disagreement with the sign flipped.
The test shape
Every case runs through both verbs together and asserts they agree, rather than
asserting each verb separately. That is deliberate: a suite where every test exercises
one verb could never have caught this, which is exactly how it survived. On a
200theheaders are compared field by field, including
Content-Lengthagainst the actual bytecount
GETreturns — that is whataws s3 cpsizes its download from, so a HEADpromising a different length would be its own wrong answer.
Also covered: ranges on a synthesized record (satisfiable and unsatisfiable),
conditionals (
If-None-Match→ 304, non-matchingIf-Match→ 412 — the cheap"has it changed?" poll), non-matching keys still 404, and an explicit
versionIdnotresolving on either verb.
Mutation-tested three ways: reverting the fix fails four tests, dropping the
versionIDguard fails the versioned case, and moving the delete-marker branch back out fails the
existing
TestS3_GetHeadObject_DeleteMarker.ListObjectsV2— agreed, and now recordedYour reasoning is right and I've written it into
docs/services.mdas a decision ratherthan leaving it implicit: 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 — a list that invented entries would be a
wrong answer, not a more complete one.
While there: the task-completion resolver turned out to be undocumented entirely —
the key shape, the seeding endpoints, and the clock gate appeared nowhere in
docs/. Thatgap is closed too, in a new
### Task-completion recordssection.The point about spore-host's tests
Worth restating, because it's the most useful line in the report: those engine-composition
tests pass only because
fetchCompletionhappens to go straight toGetObject. They wereone refactor away from not holding, and nothing in the suite would have said so. That
pipeline.CheckCompletionMarkerpolls a marker via HEAD is the concrete case — that pathwas broken this whole time.
The
"version":"dev"noteCorrect diagnosis, and left out of scope on purpose rather than silently: it's #402's
immutable-tag caveat applying to
go installbuilds, since the-Xldflag is only set bythe release build. Not a regression, and not something this PR should have quietly
touched.
Targeted at v0.85.0.
chore(release): v0.85.0 (#467)