fix(core): render a tag when a task error has no message - #41376
fix(core): render a tag when a task error has no message#41376iceteaSA wants to merge 4 commits into
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Two commits added since the original description, both worth calling out because the second one is a defect this PR would otherwise have shipped.
Worth being explicit about why CI did not catch that: it could not. There is no test on On completeness of the guard, since "add a typeof check" invites "what else is unguarded": the two mechanisms that produce a blank or non-string message here are disjoint and both covered. Effect built-ins with There is a residual: a non- Updated totals: 4 commits, +186/-6. |
Issue for this PR
Closes #41375
Type of change
What does this PR do?
A subagent task that fails with a tagged error reaches the parent as a frame with an empty error string. Two defects combine, one per commit.
errorTextreturns""for most tagged errors.Schema.TaggedErrorClasspopulates.messageonly from a field literally namedmessage. Of the 114TaggedErrorClassdefinitions inpackages/opencode/srcandpackages/core/src, 37 have one — the other 77 have a blank.message.errorTextinpackages/core/src/background-job.tsreturnederror.messageverbatim, sosettlestored an empty string as the job's error.It now prefers a non-blank
message, then_tag, thenname, then a non-blankString(error), and never returns an empty string. Tagged errors carry their tag on both_tagandname;_tagis preferred because a plainnew Error("")hasname === "Error", which is less useful but still better than nothing. Errors that already carry a real message take the first branch and are unaffected.??does not fire on an empty string. Both consumers inpackages/opencode/src/tool/task.tsusedresult.error ?? "Task failed".??substitutes only fornull/undefined, so a blank error passed straight through and the fallback was unreachable in exactly the case it was written for. Both now use||.Either fix alone is incomplete: fixing only
errorTextleaves??dead code for any other blank-string source, and fixing only??throws away the tag that would have named the failure.This is diagnosability, not behaviour. It does not change which errors occur or when a task fails — it makes the resulting frame say what went wrong.
How did you verify your code works?
Red-first, with a mutation check on each fix: revert the source change, keep the test, confirm it goes red again.
Mutation, both source files reverted with tests kept:
Each test has a regression arm asserting an error with a real message still renders that message unchanged.
errorTextis module-private, so it is tested through its observable effect — settle a job with a message-less tagged error, then readinfo.error— rather than exporting it for the test.Screenshots / recordings
Not a UI change.
Checklist