Repository navigation
fix(core): surface underlying exec error when merging generator changesets - #13664
Conversation
|
🚧 This PR requires manual testing before it's ready for review. EDIT: manual testing DONE 🚀 The two new automated tests pass on a dev engine, and I verified the integration test fails on
Repro steps are in the PR description / |
abd932f to
7a3471a
Compare
949ff0d to
a629b0e
Compare
|
Good call on the golden coverage — doing it surfaced that the fix wasn't actually enough. 👇 Expanding the Fixed by making the merge error self-contained and origin-free (a small New golden ( Landed as:
Squashed into one commit and rebased on main. Still draft pending a final manual pass, but the automated + golden coverage is in. |
a629b0e to
793802e
Compare
| @@ -0,0 +1,5 @@ | |||
| Expected stderr: | |||
|
|
|||
| ✔ viztest:generate-fail X.Xs ⡀⡄⡆⡇⣇⣧⣷⣿ | |||
There was a problem hiding this comment.
It's interesting that this still shows a green check. Makes me think we're fixing at the wrong layer.
IMO mergeEvalError shouldn't be necessary at all - if we can correctly attribute the exec failure back to this check span, the TUI should be able to show a nice rolled-up error attributed to the check; instead of a false-green check with an error message constructed from the captured stdout/stderr, you'd have a red X with the logs surfaced through the span tree.
One thing worth trying: right now "running the generator locally" (which happens within the span) actually just grabs the Changeset which is lazy. Maybe each generator should force-sync() it?
Lines 497 to 502 in dc12c3a
It'll have to sync() eventually and these already run in parallel so I don't see a reason to defer it.
Though now that I look at Changeset.Evaluate it's a no-op - maybe it should evaluate its Directories?
When a `+generate` function's changeset evaluates lazily and its backing exec (e.g. SDK codegen) fails, `dagger generate` hid the failure: the generator rendered as a green check and the user got a bare "exit code: N" with no command or stderr, in the TUI as well as plain output. Root cause: `runGeneratorLocally` grabbed the lazy Changeset but never forced it, and `Changeset.Evaluate` was a no-op -- so the exec ran later, during the merge, outside the generator's span: misattributed, with its logs hidden. Force the changeset to evaluate inside the generator's span: - `Changeset.Evaluate` now evaluates its before/after directories, so `changeset.sync` actually forces (its intended semantics). - `runGeneratorLocally` syncs the changeset after grabbing it; generators already run in parallel and it has to sync eventually. The generator now goes red and the exec error is attributed to it. Also keep a rolled-up span's logs on failure in the pretty frontend (previously shown only while running), so the exec's stderr survives in the final report instead of collapsing to a bare status. Tests: - integration: real `dagger generate` over a lazily-failing generator surfaces the command, stderr, and exit code (plain output). - golden: a Generate mode in the TestTelemetry golden flow (was call/check only) + a GenerateFail generator in viztest; the generate-fail golden pins the red row with the exec's stderr rolled up under it. Design notes in hack/designs/generate-surface-exec-error.md. Fixes dagger#13606 Signed-off-by: Tom Chauveau <[email protected]>
793802e to
273d3f1
Compare

Problem
When a generator's changeset evaluates lazily and its backing exec fails,
dagger generateleaves you with a content-free summary:It names neither the command that failed nor its stderr. The failing exec's stderr does still stream into the live progress tree, but the error summary — the artifact that survives a failed run and lands in CI logs — drops it, so the user has to scroll a (possibly collapsed) tree or re-run the changeset by hand.
Fixes #13606.
Why
The exec produces an
*ExecError(Cmd,Stderr,ExitCode), butExecError.Error()returns only"exit code: N"— the command and stderr live on the struct /Extensions(), never in the message. The changeset merge (WithChangeset/WithChangesets) then wraps it with bare%wcontext. The exec is forced lazily deep inside the merge, so the summary is all that's left.Fix
Lift the
*ExecError's command, exit code, and stderr into the message at the merge boundary via a smallmergeEvalErrorhelper, applied inWithChangeset,WithChangesets, andcheckAllPairwiseConflicts. The*ExecErrorstays in the%wchain so its extensions/origin still propagate.The shared direct-eval path (
ComputePaths/withMountedDirs/IsEmpty, used bydagger call … is-empty) is deliberately left untouched — the TUI already renders its exec span's stderr there, so enriching it would double-print.Tests
TestMergeEvalError(core/changeset_test.go) — cmd+stderr lifted, chain preserved, plain/bare errors unchanged.TestGeneratorLazyExecFailureSurfacesStderr(core/integration/generators_test.go) — drives realdagger generateagainst a lazily-failing exec. Verified it fails onmain(summary is bareexit code: 3) and passes with the fix.Design notes in
hack/designs/generate-surface-exec-error.md.