Skip to content

fix(journey): fall back to session journeyId so journey-default variables interpolate at every node (EVO-1885)#84

Merged
dpaes merged 1 commit into
developfrom
danilocarneiro/evo-1885-journey-nodes-journeyid-omitted-at-most-dispatch-sites
Jun 24, 2026
Merged

fix(journey): fall back to session journeyId so journey-default variables interpolate at every node (EVO-1885)#84
dpaes merged 1 commit into
developfrom
danilocarneiro/evo-1885-journey-nodes-journeyid-omitted-at-most-dispatch-sites

Conversation

@daniloleonecarneiro

Copy link
Copy Markdown

Summary

Follow-up to EVO-1882, which fixed journeyId for the Send Webhook node only. The audit that card required revealed the omission is systemic: of the 17 node executors that interpolate, most dispatch sites in journey-execution.workflow.ts omit journeyId.

BaseNode.interpolateNodeData resolves journey-level variable defaults via journeyRepository.findOne({ where: { id: input.journeyId } }). With journeyId undefined the lookup found nothing (silently — the try/catch swallows it), so any {{variable}} backed by a journey default was left as the literal token at runtime. Session/workflow variables were unaffected.

Fix (Option B — single-point fallback):

  • Resolve the journey id as input.journeyId ?? session.journeyId. session.journeyId is a scalar column present on both the cache (CachedJourneySession) and DB session shapes, so one change covers all current and future interpolating nodes — including conditional via selectiveInterpolateNodeData.
  • Guard the query on a resolved id: findOne({ where: { id: undefined } }) drops the condition and would return an arbitrary journey's defaults — the guard also fixes that latent bug.

Test plan

  • tsc -b clean.
  • New base.node.spec.ts (no prior spec exercised interpolateNodeData internals — node specs stub it): fallback to session.journeyId, input.journeyId precedence, the no-id guard, and a session-variable no-regression case.
  • Full temporal suite green: 24 suites / 138 tests (the 4 failures on a bare run are pre-existing EVOAI_CRM_API_TOKEN env gating in unrelated assign/transcript specs; they pass with the token set and this change doesn't touch them).

Notas

…bles interpolate at every node (EVO-1885)

Most node dispatch sites in journey-execution.workflow.ts omit journeyId, so
BaseNode.interpolateNodeData found no journey and left journey-default
{{variables}} as literal tokens at runtime (silently — the try/catch swallows
it). EVO-1882 fixed only send-webhook; the omission is systemic across the 17
interpolating nodes.

Single-point fallback: resolve the journey id as input.journeyId ?? session.journeyId.
session.journeyId is a scalar column present on both the cache (CachedJourneySession)
and DB session shapes, so one change covers all current and future nodes (including
conditional via selectiveInterpolateNodeData). Guard the query on a resolved id —
findOne({ where: { id: undefined } }) drops the condition and would return an
arbitrary journey's defaults.

New base.node.spec.ts covers fallback, input precedence, the no-id guard, and
session-variable no-regression.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @daniloleonecarneiro, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@dpaes dpaes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — EVO-1885.

Option B verified against source: interpolateNodeData resolves input.journeyId ?? session.journeyId with an id-guard (also kills the latent findOne({id: undefined}) bug). Confirmed session.journeyId is a scalar column present on both the DB and cached (CachedJourneySession.journeyId) shapes, so the fix closes all 21 dispatch sites that omitted journeyId (conditional included via selectiveInterpolateNodeData). AC2 preserves input precedence; no session/workflow-variable regression. Nit: the new spec exercises only the cache path (DB-fallback untested, LOW).

Note: evo-flow-community CI does not run jest/tsc — tests author-reported. Merging (squash) to develop.

@dpaes dpaes merged commit 35baad9 into develop Jun 24, 2026
3 checks passed
@dpaes dpaes deleted the danilocarneiro/evo-1885-journey-nodes-journeyid-omitted-at-most-dispatch-sites branch June 24, 2026 13:49
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.

2 participants