Skip to content

docs/examples: String.raw $nodeId.output pattern is fragile when output contains backticks #1427

@Wirasm

Description

@Wirasm

Summary

The recommended pattern for consuming an upstream node's output inside an inline script: body — shown in .claude/skills/archon/examples/dag-workflow.yaml and implicitly endorsed in references/parameter-matrix.md and references/workflow-dag.md — uses a String.raw template literal:

const raw = String.raw`$fetch-issue.output`;
const issue = JSON.parse(raw);

This pattern silently breaks the moment $fetch-issue.output contains a backtick, because any backtick in the substituted content terminates the template literal early. Subsequent JSON content is then parsed as JavaScript and produces cryptic Expected ";" errors.

How I hit it

While authoring the new maintainer-standup workflow, the synthesis node returned an output_format JSON payload whose brief_markdown field contained markdown code spans like `b286ad97` and `$nodeId.output`. The downstream persist inline script copied the example pattern verbatim. The whole node failed at script-load time:

4 | committed changes; pull skipped). Dev SHA: `b286ad97`.\n- Untracked files…
                                                        ^
error: Expected ";" but found "b286ad97"
    at /Users/rasmus/Projects/cole/Archon/[eval]:4:242

Diagnostic noise was very high — the entire 70KB+ script source got dumped into the error log (related to existing #1389).

Why this is brittle

output_format payloads, AI-generated text, and anything routed through a markdown body will routinely contain backticks. The current example only works because gh issue view --json happens to produce backtick-free JSON. Any workflow that takes the example at face value and passes through realistic content will hit this.

Suggested fix

JSON is a strict subset of JavaScript expression syntax (object literals, double-quoted strings with JSON-compatible escape sequences, JSON numbers, true/false/null). The substituted output can be assigned directly without any wrapper:

const data = $fetch-issue.output;     // already a valid JS object/array literal

This avoids the backtick hazard entirely, and removes the explicit JSON.parse step. Edge cases I checked:

  • Backticks inside double-quoted JSON strings: literal characters in JS, no interpretation.
  • ${...} inside double-quoted JSON strings: not interpolated in JS (only template literals interpolate).
  • Newlines, Unicode escapes, JSON's six escape sequences (\\\", \\\\, \\n, \\r, \\t, \\uXXXX): all are valid JS escape sequences with the same semantics.

Concrete changes proposed

  1. Update .claude/skills/archon/examples/dag-workflow.yaml (the extract-labels node) to use the direct-assignment pattern, with a one-line comment explaining why it's safer than String.raw.
  2. Add a short note to references/workflow-dag.md (Script Node section) and references/parameter-matrix.md (Silent failures section) calling out the backtick hazard with String.raw and recommending the direct-assignment idiom.
  3. Optionally also reflect this in archon.diy/guides/script-nodes/.

Happy to send a PR if the approach is agreed.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is brokendocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions