Skip to content

feat(eager): add FATAL error when a node is deferred due to an exception - #1357

Merged
jasmith-hs merged 1 commit into
masterfrom
jasmith_hubspot/fatal-error-deferred-exception
Oct 29, 2026
Merged

jasmith-hs merged 1 commit into
masterfrom
jasmith_hubspot/fatal-error-deferred-exception

Conversation

@jasmith-hs

Copy link
Copy Markdown
Contributor

Description

In eager execution mode, when a DeferredValueException reaches ExpressionNode or TagNode, the node falls back to handleDeferredNode and its original image is written to the output. Eager execution normally handles deferral through deferred tokens, so getting to this catch means the node couldn't be handled (for example: output too big, too many deferred tokens, or a modification of a temporary import alias). Until now this happened silently: rendering looked successful even though the output was incomplete.

This PR adds a FATAL TemplateError from the exception, with the node's line number and start position, so callers can detect that the output is incomplete.

Default execution mode is not changed. There, deferring a node is the expected way of preserving deferred values for a later render, and adding a FATAL error would make Jinjava.render() throw for every template that uses deferred values.

BRAVE

Backwards Compatibility

  • Eager execution mode only. Eager execution is still Beta.
  • Templates that previously rendered with silently deferred nodes in eager mode will now report a FATAL error. With Jinjava.render() this means a FatalTemplateErrorsException, and the configured ErrorHandlingStrategy applies.
  • Default execution mode is unchanged.

Rollout and Rollback Plan

  • Ships in the next jinjava release.
  • Roll back by reverting this PR.

Automated Testing

  • EagerAstDotTest: checks that a deferred ExpressionNode reports a FATAL error.
  • EagerTest.itFailsOnModificationInAliasedMacro: checks for the FATAL "Cannot modify temporary import alias" error.
  • EagerSetTagTest / EagerDoTagTest itLimitsLength: check for the new FATAL EXCEPTION error alongside OUTPUT_TOO_BIG.
  • DeferredTest still passes, confirming default mode is unaffected.

Verification

  • mvn clean verify passes (2238 tests).

Expect Dependencies to Fail

  • Consumers using eager execution may now see FATAL errors on templates whose nodes were being deferred because of an exception. This is intended: those outputs were already incomplete.
REVIEWERS: Please review both the code changes and the answers above, and validate that they match the expectations for BRAVE

This description was authored by Claude Code.

🤖 Generated with Claude Code

In eager execution mode, a DeferredValueException reaching ExpressionNode
or TagNode means the node could not be handled and is output verbatim.
Surface this as a FATAL interpreter error so callers know the output is
incomplete. Default execution mode is unchanged, since deferring nodes
there is the expected way of preserving deferred values.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jasmith-hs jasmith-hs self-assigned this Oct 29, 2026
@jasmith-hs
jasmith-hs marked this pull request as ready for review October 29, 2026 16:09
@jasmith-hs
jasmith-hs merged commit ca345cd into master Oct 29, 2026
7 checks passed
@jasmith-hs
jasmith-hs deleted the jasmith_hubspot/fatal-error-deferred-exception branch October 29, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants