Skip to content

Preserve template expression traceback errors - #1635

Merged
EmilStenstrom merged 1 commit into
masterfrom
fix/better-traceback-errors-1597
May 1, 2026
Merged

EmilStenstrom merged 1 commit into
masterfrom
fix/better-traceback-errors-1597

Conversation

@EmilStenstrom

@EmilStenstrom EmilStenstrom commented May 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1597.

When a multi-node template expression raised while Django template debug mode was enabled, StringifiedNode could become Django's culprit node without carrying the metadata Django expects for traceback annotation. That replaced the original rendering error with an unrelated AttributeError.

This preserves the wrapped node's template metadata, and falls back to the active render context origin when needed, so the original exception is surfaced.

Validation

  • uv run pytest tests/test_expression.py -q
  • uv run tox -e ruff,mypy

@EmilStenstrom
EmilStenstrom force-pushed the fix/better-traceback-errors-1597 branch from 91b5359 to 593d89b Compare May 1, 2026 22:23
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

Comparing PR changes against master branch:

Benchmarks that have stayed the same:

Change Before [4891c2d] After [44a0478] Ratio Benchmark (Parameter)
62.1±0.9ms 61.7±0.7ms 0.99 Components vs Django.timeraw_render_lg_first('django')
220±4ms 223±4ms 1.01 Components vs Django.timeraw_render_lg_first('django-components')

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

Comparing PR changes against master branch:

Benchmarks that have stayed the same:

Change Before [4891c2d] After [f777efb] Ratio Benchmark (Parameter)
61.8±0.5ms 62.3±0.9ms 1.01 Components vs Django.timeraw_render_lg_first('django')
220±3ms 221±3ms 1 Components vs Django.timeraw_render_lg_first('django-components')

@EmilStenstrom
EmilStenstrom force-pushed the fix/better-traceback-errors-1597 branch from 593d89b to 554aac6 Compare May 1, 2026 22:33
@EmilStenstrom
EmilStenstrom marked this pull request as ready for review May 1, 2026 22:34
@EmilStenstrom
EmilStenstrom enabled auto-merge May 1, 2026 22:35
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Performance Benchmark Results

Comparing PR changes against master branch:

Benchmarks that have stayed the same:

Change Before [4891c2d] After [5444738] Ratio Benchmark (Parameter)
62.3±0.9ms 63.1±1ms 1.01 Components vs Django.timeraw_render_lg_first('django')
220±3ms 218±2ms 0.99 Components vs Django.timeraw_render_lg_first('django-components')

@EmilStenstrom
EmilStenstrom merged commit b3db7b2 into master May 1, 2026
15 checks passed
@EmilStenstrom
EmilStenstrom deleted the fix/better-traceback-errors-1597 branch May 1, 2026 22:36
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.

Better traceback errors

1 participant