Repository navigation
fix(taskproto): lost outputs and failing commands both lose their completion record (#561, #566) - #567
Merged
Conversation
…pletion record (#561, #566) Two ends of the same defect class: the wrapper computes failure information and then the record doesn't reflect it. #561: OUT_RC (the stage-out `aws s3 cp` exit code) was assigned in the stage-out loop and never read anywhere else. A declared output that failed to upload left the completion record at state=completed, exit_code=0, retry_class="" even though the artifact never reached its destination. Classification now has a third branch consulting OUT_RC, gated behind STAGE_RC and rc both being clean, with its own retry class (RetryOutputDeliveryError="output_delivery_error") since compute already succeeded and only delivery needs retrying. #566: confirmed root cause via reproduction, not just inspection. The wrapper's own comment says "we do NOT set -e", but pkg/launcher/ bootstrap.go concatenates this generated script onto the tail of /tmp/spawn-command.sh, whose own preamble is a literal `set -e` — the two run as ONE bash invocation, not two, so the wrapper silently inherited -e despite its comment. A failing user command (host subshell or `docker run`) then aborted the whole script at that line, before `rc=$?` was ever captured, so stage-out/classification/the completion-record write never ran — exactly the reported symptom of a failed task producing no completion.json/.exitcode/SPAWN_COMPLETE and riding out its full TTL instead of self-terminating. Fixed by making the wrapper explicitly `set +e` its own preamble instead of relying on the embedding caller's shell state. Both fixes verified with exec-based tests (real bash, stand-in aws/ docker/sudo on PATH) that fail without the fix and pass with it, in addition to text-assertion tests on the generated script.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Sep 5, 2026
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.
Summary
Two ends of the same underlying defect: the task-completion wrapper
(
pkg/taskproto/wrapper.go) computes failure information and then thedurable completion record doesn't reflect it, in different ways for
different failure modes.
#561 — a failed output upload was reported as success
OUT_RC(the stage-outaws s3 cpexit code) was assigned in thestage-out loop and never read anywhere else — confirmed by grep in the
issue report. A declared output that failed to upload left the
completion record at
state: completed,exit_code: 0,retry_class: ""even though the artifact never reached its S3destination.
Fix: classification now has a third branch consulting
OUT_RC,checked only after
STAGE_RCandrcare both confirmed clean (so astage-in or command failure still takes priority). It gets its own
retry class,
RetryOutputDeliveryError("output_delivery_error"),distinct from
staging_error/app_error: the compute alreadysucceeded, so a retry only needs to redeliver the output. Marked
Retryable() == truesince output-delivery failures are more oftentransient (S3 hiccup) than an intrinsic defect.
#566 — a task whose command failed wrote NO completion record at all
Root cause CONFIRMED via reproduction, not just inspection. The
wrapper's own comment says "we do NOT set -e", and that's true of the
wrapper's own text — but
pkg/launcher/bootstrap.go's/tmp/spawn-command.shpreamble is a literal#!/bin/bash\nset -e\n...,and the wrapper text is written onto the TAIL of that same file and
executed as ONE bash invocation, not sourced or exec'd separately. A
shell option set early in a script stays in effect for the rest of
that script, so the wrapper silently inherited
-efrom the preambleit gets embedded into.
Under that inherited
-e, a failing user command — host subshell ordocker run, it doesn't matter which — aborted the entire scriptat the point of failure, before
rc=$?was ever captured. Stage-out,classification, and the completion-record write
(
completion.json/.exitcode/SPAWN_COMPLETE) never ran. That isexactly the reported symptom: a failed task producing nothing under
s3://.../tasks/<id>/,spawn task statusreportingrunningindefinitely, and the box riding out its full TTL instead of
self-terminating on failure.
Reproduced locally by concatenating the generated wrapper after
bootstrap.go's exact
set -epreamble and running the combined scriptunder real bash with a stand-in
dockerthat exits non-zero:completion.json/.exitcode/SPAWN_COMPLETEwere never writtenuntil the fix was applied. Confirmed on both the containerized
(
docker run) and host (bare subshell) command paths.Fix: the wrapper now explicitly
set +es its own preamble(
set +e -u -o pipefail) instead of relying on the embedding caller'sshell state — correct regardless of whatever script it gets appended
to.
Why together
Same root shape, opposite symptoms: #561 turns a failure into a false
success; #566 turns a failure into silence. Fixing them together gave
one coherent read of the wrapper's control flow (stage-in → command →
stage-out → classify → write) instead of two patches that might miss
each other's edge cases.
Tests
TestGenerateWrapper_OutputDeliveryFailureClassification— textassertion that the OUT_RC branch exists with correct priority
ordering (Task path discards failure information: a lost output is reported as completed/exit 0, and a stage-in failure can produce no record at all #561).
TestGenerateWrapper_StageOutFailureExecClassifiesAsFailed—exec-based: runs the real generated script with a stand-in
awswhere one output's upload fails; asserts the real completion.json on
disk says
state=failed,retry_class=output_delivery_error.Fails without the fix (pre-fix code doesn't even compile against
this test, since
RetryOutputDeliveryErrordoesn't exist yet);passes with it.
TestGenerateWrapper_ExplicitSetPlusE— text assertion that thewrapper's preamble is
set +e -u -o pipefail(A task whose command fails writes no completion record at all, so the box rides to TTL instead of self-terminating #566).TestGenerateWrapper_SurvivesEmbeddingAfterSetE— exec-based:reproduces bootstrap.go's exact
set -e+ wrapper concatenation,runs it under real bash with a stand-in
docker runthat exits 3;asserts completion.json/.exitcode/SPAWN_COMPLETE are all written
with the correct state/exit_code/retry_class. This is the test that
reproduces A task whose command fails writes no completion record at all, so the box rides to TTL instead of self-terminating #566 end-to-end — verified failing before the
set +efix (manually, outside the Go test harness, by running the
equivalent bash concatenation directly) and passing after.
TestRetryClass_Retryableextended with the new class.TestGenerateWrapper_Structureupdated for the newset +e -u -o pipefailpreamble text.make checkclean.make check-docsclean (no drift; only a plainprose doc —
docs/workflow-adapter-protocol-rfc.md— was touched, notgenerated flag/help text). All
lambda/*/go.modnested modules buildclean, no
go mod tidyneeded. No strayautoscale-orchestratorbinary in the diff.
Process note on #566
This is a confirmed root-cause fix, not a defensive/hardening
guess: the exact mechanism (inherited
-eacross a scriptconcatenation) was pinned down and reproduced in isolation before
being fixed, and the fix's
SurvivesEmbeddingAfterSetEtestreconstructs the real embedding path (
pkg/launcher/bootstrap.go'sliteral preamble + this wrapper) rather than a synthetic stand-in.