Skip to content

Allow Vars in page metadata - #6925

Open
harsh21234i wants to merge 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/6923-dynamic-page-meta
Open

Allow Vars in page metadata#6925
harsh21234i wants to merge 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/6923-dynamic-page-meta

Conversation

@harsh21234i

@harsh21234i harsh21234i commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #6923.

@rx.page evaluated State Vars for title and description as Python
booleans, raising VarTypeError. Dynamic descriptions could also fail during
metadata compilation.

Changes

  • Allow str | Var | None for @rx.page metadata.
  • Replace Var-unsafe truthiness checks with explicit is not None checks.
  • Fix dynamic metadata handling for 404 pages.
  • Add regression tests for decorator, compiler, and 404 metadata paths.
  • Add a bugfix news fragment.

Testing

  • Focused unit tests: 205 passed, 1 skipped
  • Ruff format: passed
  • Ruff lint: passed
  • git diff --check: passed

Review in cubic

@harsh21234i
harsh21234i requested a review from a team as a code owner August 21, 2026 18:40

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 7 files

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR allows reactive Vars in page titles and descriptions while avoiding Var-unsafe truthiness evaluation.

  • Widens page metadata types through decorator, registration, and compiler boundaries.
  • Preserves supplied Vars and empty-string values using explicit None checks.
  • Adds regression coverage for decorator, compiler, and 404 metadata paths.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
reflex/page.py Accepts title and description Vars and preserves all explicitly supplied values without evaluating their truthiness.
reflex/app.py Updates 404 metadata fallback behavior to default only when title or description is absent.
reflex/compiler/utils.py Carries Vars into title and description components using their supported child and prop contracts.
tests/units/test_page.py Verifies the page decorator preserves reactive title and description Vars.
tests/units/test_app.py Verifies 404 preparation does not evaluate or replace supplied metadata Vars.
tests/units/compiler/test_compiler.py Verifies a reactive description is retained as the Description component's content Var.

Reviews (2): Last reviewed commit: "Merge upstream main into page metadata f..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Aug 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing harsh21234i:fix/6923-dynamic-page-meta (efefbd2) with main (d86f167)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

@rx.page and add_meta reject State Vars for title/description (VarTypeError)

1 participant