Skip to content

fix(automation): flow string templates serialize object tokens readably, never [object Object] (#3450)#3470

Open
os-zhuang wants to merge 1 commit into
mainfrom
fix/3450-error-object-serialization
Open

fix(automation): flow string templates serialize object tokens readably, never [object Object] (#3450)#3470
os-zhuang wants to merge 1 commit into
mainfrom
fix/3450-error-object-serialization

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

What & why

Closes #3450 (split from #3425; the readonly-strip half shipped in #3465).

A flow string field that embeds an object-valued token rendered as the useless [object Object]. The most common trigger is a fault handler surfacing the engine's $error — set as an object {nodeId, message, output} (engine.ts:2585) — in a notify body (message: 'Conversion failed: {$error}'), or any node writing an object token into a string field.

Two coercion sites produced it:

  • interpolateString's multi-token branch did String(value) (builtin/template.ts).
  • notify-node did String(interpolate(...)) for title/body — a sole {$error} token resolves to the raw object, then String()[object Object].

Fix

  • New shared stringifyForTemplate(value) helper: objects/arrays → JSON.stringify (legible, still carries the message), primitives → String, null/undefined''.
  • Used in interpolateString's embedded branch and notify-node's title/body.
  • Unchanged: the sole-token branch still returns the raw value so typed config fields keep their type (fields: { count: '{n}' } stays a number), and {$error.message} still resolves to just the message string — the documented cleanest author form.

Notes on scope

The originally-reported 16.1.0 symptom (a failed create_record's own error as [object Object]) is already fixed on main — crud-nodes returns (err as Error).message, and both objectui runs surfaces render readably (FlowRunsPanel via a .message helper, FlowRunsPage via JSON.stringify). This PR closes the remaining, demonstrable platform path: object tokens in flow string templates.

Verification

  • New template-object-token.test.ts (7 cases): embedded $error → readable JSON (asserts not [object Object], contains the message); {$error.message} → message string; sole token preserves the raw object; primitives unchanged; circular object doesn't throw.
  • Red-proof: reverting the multi-token branch to String() fails exactly the embedded-object test.
  • Full @objectstack/service-automation suite green (354 tests, incl. notify-node).

🤖 Generated with Claude Code

…ly, never [object Object] (#3450)

A flow string field embedding an object-valued token — notably the engine's
`$error` ({nodeId, message, ...}) in a fault handler's notify body — rendered as
[object Object]: interpolateString's multi-token branch and notify-node both
coerced via String().

- New shared stringifyForTemplate helper (builtin/template.ts): objects/arrays
  JSON-serialized (legible, still carries the message), primitives pass through,
  null/undefined → ''.
- interpolateString embedded branch + notify-node title/body use it. Sole-token
  branch still returns the raw value (typed fields keep their type); {$error.message}
  still resolves to the message string.

Split from #3425 (readonly-strip half shipped in #3465).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

6 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/automation/webhooks.mdx (via packages/services)
  • content/docs/kernel/runtime-services/audit-service.mdx (via packages/services)
  • content/docs/kernel/runtime-services/index.mdx (via packages/services)
  • content/docs/kernel/runtime-services/settings-service.mdx (via packages/services)
  • content/docs/plugins/packages.mdx (via packages/services)
  • content/docs/protocol/kernel/i18n-standard.mdx (via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 24, 2026 4:54pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

automation: step error objects can surface as "[object Object]" in run-history consumers (split from #3425)

1 participant