Skip to content

Fail Core.Case on expression evaluation errors under expression v3 - #354

Open
raquelgraca wants to merge 1 commit into
developfrom
fail-case-on-expression-eval-error
Open

raquelgraca wants to merge 1 commit into
developfrom
fail-case-on-expression-eval-error

Conversation

@raquelgraca

Copy link
Copy Markdown

Why

A variable = expression assignment in a journey compiles to a Core.Case block whose exit name is the expression. When the expression parses but fails while evaluating, Case.evaluate_outgoing/5 stores the exit name, so the journey silently continues with the expression's source text as the value.

A customer hit this reading a contact field that was never written for the contact:

Expression Evaluation error Value stored today
contact.program_quit_at > now() attribute is not found: program_quit_at "contact.program_quit_at > now()"
datetime_add(contact.program_quit_at, 2, "W") <= now() expression is not a number: nil the source text
if(is_nil_or_empty(contact.program_quit_at), false, contact.program_quit_at > now()) attribute is not found: program_quit_at the source text

A field written as null evaluates to false as expected; only never-written fields hit this.

What changes

flowchart TD
    A[evaluate exit name] --> B{result}
    B -- ":parse error" --> C[store exit name<br/>routing labels, unchanged]
    B -- "other error" --> D{expression_mode}
    D -- ":v3" --> E[raise Expression.Error]
    D -- ":v2 / nil" --> C
    B -- nil --> C
    B -- value --> F[store value]
Loading
  • Parse errors still store the exit name: when routing exits are plain labels ("Exit for CheckYes") that don't parse, and rely on this.
  • Only v3 journeys change, so no existing journey changes behaviour.
  • Raising matches how every other failing expression in a journey behaves; engage already treats Expression.Error as non-retryable.

Follow-up

  • A version bump (mix.exs + README, currently 6.15.3) and release are still needed.
  • The engage PR that shows these errors to journey authors (instead of "contact support") will follow.

Testing

Four new BlockTest cases (v2 stores the source text, v3 raises, a null field still evaluates on v3, a routing label is still stored on v3). mix test: 212 tests, 0 failures.

🤖 Generated with Claude Code

A `variable = expression` assignment compiles to a Core.Case block whose
exit name is the expression. When that expression parsed but failed while
evaluating (e.g. comparing a never-written contact field against a date),
the block stored the exit name, so the journey carried on holding the
expression's own source text as the value.

Under expression v3 semantics the evaluation error is now raised, so the
journey fails visibly. Parse errors still fall back to the exit name,
because routing exits are named with plain labels that don't parse, and
v2 journeys keep today's behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@raquelgraca
raquelgraca marked this pull request as ready for review November 19, 2026 18:36
@raquelgraca raquelgraca self-assigned this Nov 19, 2026
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.

1 participant