Skip to content

feat(temporal): export resolveTemplate - #286

Open
levyshachar2LR wants to merge 2 commits into
synergycodes:mainfrom
levyshachar2LR:feat/export-resolve-template
Open

levyshachar2LR wants to merge 2 commits into
synergycodes:mainfrom
levyshachar2LR:feat/export-resolve-template

Conversation

@levyshachar2LR

@levyshachar2LR levyshachar2LR commented Nov 23, 2026 •

Copy link
Copy Markdown

Closes #281.

What

resolveTemplate is now exported from the root entry of @workflowbuilder/temporal, so an executor outside this repository can resolve {{namespace.path}} references the same way the reference worker does.

A separate commit makes the resolver follow only own properties. Before, a path such as {{nodes.x.constructor}} reached the object's prototype instead of failing as unresolved.

Changes

feat(temporal): export resolveTemplate

  • packages/temporal/src/core-contract.ts re-exports resolveTemplate, and src/index.ts exports it from the root entry only. /workflow is unchanged.
  • test/api-surface.test.ts pins the new name.
  • The README gets a section after "Failures and retries" that shows the call and names template_malformed and template_unresolved. It documents only the form the variable picker stores: no whitespace inside the braces, plus the ? and | default:'…' modifiers.
  • .changeset/export-resolve-template.md, a minor bump.

fix(execution-core): resolve template paths through own properties only

  • getNestedValue checks Object.hasOwn at each step of the path. Array indices and length are own properties, so they still resolve.
  • New tests in resolve-template.test.ts cover constructor, toString and __proto__, both nested and directly under a namespace, and the ? and default: fallbacks for them. Every one of those fails without the fix.
  • Regression guards that pass both before and after: array indices and an array's length, an own __proto__ key as JSON.parse creates it, and null-prototype objects.
  • The changeset mentions the change, because it changes execution behaviour.
  • This matches the check that examples/workflow-builder-temporal/worker/src/evaluate-branches.ts already does.
  • No patched() guard is needed for this behaviour change. resolveTemplate runs only inside executors, which are activities, and nothing under packages/temporal/src/workflow calls it, so workflow replay is unaffected.

The helper that resolves a whole config object is not in this PR, as agreed in the issue.

Question: release order with #76

Once this is released, resolveTemplate is public API. The parser on main still accepts whitespace inside the braces ({{ nodes.x }}), which #76 removes. The README here documents only the no-whitespace form, but if a release ships this export before #76 lands, #76's tightening becomes a breaking change to an exported function. Do you plan to release #76 together with this, or before it?

How to check

  • pnpm test passes.
  • For @workflowbuilder/temporal: lint, typecheck, test, build, [email protected] and attw --pack --profile esm-only pass.
  • pnpm check passes except the apps/docs typecheck, which fails the same way on a clean main in my environment (missing virtual:starlight/* modules).
  • I installed the packed tarball in a fresh project outside the repo and ran it under strict TypeScript with Node 22. The checks used references shaped like the picker's (UUID node ids, global.<id>) and passed. The errors it throws are instanceof the exported PermanentNodeExecutionError and carry the right code. dist/workflow/index.js does not include it.
  • The resolver changes merge cleanly with feat(sdk) Variable enhancement  #76, and its resolver tests pass on the merged result.

🤖 Generated with Claude Code

levyshachar2LR and others added 2 commits November 23, 2026 14:23
Executors outside this repository can now resolve `{{namespace.path}}`
references the same way the reference worker does. Adds it to the pinned
root API surface, documents the call and its two error codes in the README,
and adds a changeset.

Refs synergycodes#281

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`getNestedValue` used a plain property lookup, so `{{nodes.x.constructor}}`
reached the prototype chain instead of failing as unresolved. Each step now
checks `Object.hasOwn`. Array indices and `length` keep resolving.

Refs synergycodes#281

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export resolveTemplate from @workflowbuilder/temporal

1 participant