Skip to content

fix(server): workflow failure reasons no longer end in a broken character - #41808

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
tiliakoos:fix/workflow-failure-reason-emoji
Nov 24, 2026
Merged

juliusmarminge merged 3 commits into
pingdotgg:mainfrom
tiliakoos:fix/workflow-failure-reason-emoji

Conversation

@tiliakoos

Copy link
Copy Markdown
Contributor

Problem

Workflow failure reasons and unreadable wait-signal details are cut at 2,000 UTF-16 code units with .slice(0, 2000) in text() and waitClaimed (apps/server/src/workflows/workflow.ts) and again when persisting runPaused and stepEnded (apps/server/src/workflows/WorkflowStore.ts). When unit 2,000 falls inside an emoji or other non-BMP character—either in the original error or after StepFailed's ${step}: prefix or the wait-error prefix shifts it across the boundary—the cut leaves a lone high surrogate. SQLite replaces that lone surrogate with U+FFFD (\ufffd) in workflow_runs.detail and workflow_steps.detail, while text() and the workflow.run_paused milestone event carry the lone surrogate directly.

Change

Added detailCut in apps/server/src/workflows/WorkflowStore.ts using the shared splitsSurrogatePair helper from @t3tools/shared/assistantCitations to stop at 1,999 units when unit 2,000 would split a surrogate pair. Used detailCut at all five workflow failure-reason cut sites: runPaused and stepEnded in WorkflowStore.ts, and text() (string and error/cause branches) and the wait-step unreadable-signal detail in workflow.ts. Existing 2,000-unit limits, short strings, and cuts between whole characters are unchanged.

Scope

A small, focused fix for an obvious bug, sibling to #41723 (stepResult in WorkflowStore.ts), #41629 (WorktreeSetupTracker.ts), and #41669 (ProjectCloneTracker.ts). Limited to workflow failure reasons; other cuts such as run and reference titles are untouched. Includes a standalone repro below, so it needs no issue.

Verification

Three new regression tests across apps/server/src/workflows/WorkflowStore.test.ts (runPaused persisted detail and milestone reason, plus stepEnded persisted detail) and apps/server/src/workflows/Workflows.test.ts (text() string/error/cause cuts and wait-step unreadable-signal detail). With workflow.ts and WorkflowStore.ts from base 85aaef42d4, all three fail; on head baf455a5a6, both files pass.

$ vp test run apps/server/src/workflows/WorkflowStore.test.ts apps/server/src/workflows/Workflows.test.ts    # base source
   × a long failure detail is cut without leaving half an emoji
   × error text cuts at 2,000 units without leaving half an emoji
   × a long unreadable wait signal error is cut without leaving half an emoji
      Tests  3 failed | 38 passed (41)

$ vp test run apps/server/src/workflows/WorkflowStore.test.ts apps/server/src/workflows/Workflows.test.ts    # head
      Tests  41 passed (41)

vp run check:changed upstream/main passes (format, lint, knip 2/2, graphql, typecheck across 3 packages, and 43 tests across 3 files).

Repro: save as build/repro.sh and run bash build/repro.sh <label> on each commit from a checkout with dependencies installed and jq (no account or provider needed)
cli=$PWD/apps/server/src/bin.ts; t3() { node "$cli" "$@"; }
scratch=$PWD/build/repro-$1; rm -rf "$scratch"
export T3CODE_HOME=$scratch/state T3CODE_WORKFLOWS=$scratch/workflows
mkdir -p "$T3CODE_HOME/userdata" "$T3CODE_WORKFLOWS" "$scratch/project"
echo '{"workflowsEnabled":true}' > "$T3CODE_HOME/userdata/settings.json"
cat > "$T3CODE_WORKFLOWS/failing.ts" <<'TS'
export default T3.workflow("failing", {version: 1, payload: Schema.Struct({})},
  Effect.fn(function* () {
    yield* T3.step("work", {returns: Schema.Void},
      Effect.fail(new Error(`${"a".repeat(1993)}🚀bbbb🚀 done`)));
  }));
TS
inspect='let s="";process.stdin.on("data",(d)=>(s+=d)).on("end",()=>{const d=JSON.parse(s);const rd=d.run.detail;const sd=d.steps[0].detail;console.log("run:",d.run.status,"tail:",JSON.stringify(rd.slice(-4)),"len:",rd.length,"hasFFFD:",rd.includes("\ufffd"));console.log("step:",d.steps[0].status,"tail:",JSON.stringify(sd.slice(-4)),"len:",sd.length,"hasFFFD:",sd.includes("\ufffd"))})'
node "$cli" serve --port 15347 --no-browser "$scratch/project" > "$scratch/server.log" 2>&1 & server=$!
trap 'kill "$server" 2>/dev/null; wait "$server" 2>/dev/null || true' EXIT
ready=$T3CODE_HOME/userdata/server-runtime.json
for _ in $(seq 60); do [ -f "$ready" ] && break; sleep 1; done
[ -f "$ready" ] || { cat "$scratch/server.log"; exit 1; }
echo '$ rid=$(t3 workflow start failing --key one --json | jq -r .run.runId)'
rid=$(t3 workflow start failing --key one --json | jq -r .run.runId); sleep 2
echo '$ t3 workflow show "$rid" --json | node -e '"'$inspect'"
t3 workflow show "$rid" --json | node -e "$inspect"

Setup: macOS, Node 26.13.1, real t3 serve with fresh isolated state on each run. The step error places one 🚀 at unit 1,999 of step.detail (text() / stepEnded) and another at unit 1,999 of run.detail after the work: prefix (runPaused). The base run used workflow.ts and WorkflowStore.ts from 85aaef42d4.

85aaef42d4 (base):

$ rid=$(t3 workflow start failing --key one --json | jq -r .run.runId)
$ t3 workflow show "$rid" --json | node -e 'let s="";process.stdin.on("data",(d)=>(s+=d)).on("end",()=>{const d=JSON.parse(s);const rd=d.run.detail;const sd=d.steps[0].detail;console.log("run:",d.run.status,"tail:",JSON.stringify(rd.slice(-4)),"len:",rd.length,"hasFFFD:",rd.includes("\ufffd"));console.log("step:",d.steps[0].status,"tail:",JSON.stringify(sd.slice(-4)),"len:",sd.length,"hasFFFD:",sd.includes("\ufffd"))})'
run: paused tail: "aaa" len: 2000 hasFFFD: true
step: failed tail: "bbb" len: 2000 hasFFFD: true

baf455a5a6 (fix):

$ rid=$(t3 workflow start failing --key one --json | jq -r .run.runId)
$ t3 workflow show "$rid" --json | node -e 'let s="";process.stdin.on("data",(d)=>(s+=d)).on("end",()=>{const d=JSON.parse(s);const rd=d.run.detail;const sd=d.steps[0].detail;console.log("run:",d.run.status,"tail:",JSON.stringify(rd.slice(-4)),"len:",rd.length,"hasFFFD:",rd.includes("\ufffd"));console.log("step:",d.steps[0].status,"tail:",JSON.stringify(sd.slice(-4)),"len:",sd.length,"hasFFFD:",sd.includes("\ufffd"))})'
run: paused tail: "aaaa" len: 1999 hasFFFD: false
step: failed tail: "bbbb" len: 1999 hasFFFD: false

Not checked: web and mobile workflow views (they render the stored detail fields and are not changed), Linux and Windows (pure UTF-16 string slicing with no platform-specific paths). The fix guards UTF-16 surrogate pairs; a multi-code-point grapheme cluster can still be split at a code-point boundary.

Gemini 4 Neon via T3 Code

…cter

Workflow error text, unreadable wait signal errors, and paused or failed
details cut at 2,000 units could end in a lone surrogate when an emoji
straddled the limit. Those cuts now stop one unit earlier.
@github-actions github-actions Bot added the vouch:unvouched Author is not yet trusted in the VOUCHED list. label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Workflow detail truncation now uses a shared helper that limits text to 2,000 code units without splitting surrogate pairs. Tests cover error text, paused runs, step details, and wait-reopen problem details.

Changes: Workflow detail truncation

Layer / File(s) Summary
Shared truncation and workflow integration
apps/server/src/workflows/WorkflowStore.ts, apps/server/src/workflows/workflow.ts, apps/server/src/workflows/WorkflowStore.test.ts, apps/server/src/workflows/Workflows.test.ts
detailCut limits text to 2,000 code units and avoids splitting surrogate pairs. Workflow error text, paused-run reasons, step details, and wait-reopen problem details use the helper. Tests cover these paths with long text containing an emoji.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • pingdotgg/t3code#41723: Addresses surrogate-pair splits in the same store’s 8,000-unit stepResult truncation path.

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to f654f

Workflow failure reasons are now truncated without splitting an emoji or other surrogate pair. The change is small and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: workflow failure reasons are truncated so they no longer end in a broken surrogate-pair character. It is concise and specific, and it follows the conventional commit s…
Description check Passed The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections. The Problem section states the bug and its reproduction. The Change section names the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: workflow failure reasons are truncated so they no longer end in a broken surrogate-pair character. It is concise and specific, and it follows the conventional commit style used by the repository template. It matches the changeset in WorkflowStore.ts and workflow.ts.

Full details: Description check

Explanation

The description follows the repository template closely. It has Problem, Change, Scope, and Verification sections. The Problem section states the bug and its reproduction. The Change section names the helper and the five cut sites. The Scope section explains why no issue link is needed and names sibling fixes. The Verification section lists the regression tests, before and after results, and a standalone repro. Minor gaps: the Scope section does not link an issue, but it gives a reason for omitting one, as the template allows. The description also states the untested areas (web, mobile, Linux, Windows). The author's agent model line is present at the end.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between baf455a and f654f2c.

Files selected for processing: 2

  • apps/server/src/workflows/WorkflowStore.test.ts
  • apps/server/src/workflows/Workflows.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 24, 2026
juliusmarminge and others added 2 commits November 24, 2026 01:30
The store test covers the stored step and run details, and the text()
test covers the string and cause paths that every other site reuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:S 10-29 changed lines (additions + deletions). label Nov 24, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Ran the real server and CLI on Linux with fresh isolated databases and workflows enabled on both commits. Loaded the same failing workflow, started it with key one, waited three seconds, and inspected workflow show --json.

Before After
d244be81ba f654f2ce7c
Both persisted details end in U+FFFD at 2,000 UTF-16 units. CLI capture · Full JSON Both persisted details are 1,999 units, with no replacement character or lone surrogate. CLI capture · Full JSON

Reproduction driver · Workflow seed

Not shown:

  • The workflow.run_paused milestone reason was not inspected; this reproduction verified persisted run and step details.
  • Unreadable wait-signal details were not exercised because the supplied reproduction only triggers a failing workflow step.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 24, 2026
@juliusmarminge
juliusmarminge merged commit 364ca47 into pingdotgg:main Nov 24, 2026
55 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 24, 2026
@tiliakoos
tiliakoos deleted the fix/workflow-failure-reason-emoji branch November 24, 2026 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants