Skip to content

fix: render component calls inside tables, escape NUL in compiled templates, fix the landing demo (#235) - #239

Merged
JuroOravec merged 5 commits into
mainfrom
fix/render-bugs-235
Oct 22, 2026
Merged

JuroOravec merged 5 commits into
mainfrom
fix/render-bugs-235

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Fixes #235. Each bug was found by the Vue compile check in #234.

Fixes

  1. The landing page demo crashed when it rendered. editor_invite_panel.py passed c-name="member.name" to a chip inside a Vue v-for. c-name is evaluated on the server, but member exists only in the browser, so rendering failed with KeyError: 'member'.
    • The chips are now repeated with <c-for each="member in members">, as the docs recommend.
    • The demo's three deliberate mistakes are kept, and the hover notes match.
    • A new test renders the demo; it fails on the old version.
  2. A component call inside a table failed in a Vue component. This affected <table>, <tbody>, <thead>, <tfoot>, <tr> and <colgroup>, with the error "Foster parenting moved this element before the nearest open table".
    • Cause: crates/citry_vue_compiler parsed the generated template with vize's default options. Those options read Citry's component-call tags as plain HTML elements, so vize's table rules moved them out of the table. Vize is the Rust Vue compiler Citry uses.
    • Fix: the compiler now parses the generated template with the declared call tags and <component> read as components.
    • Tests: every table context, keyed <c-for> runs, <c-if>, v-if and fills, plus a mounted and hydrated browser test.
  3. A NUL character in a template produced Python that couldn't run. escape_text_in_triple_quotes in crates/citry_template_parser/src/lang/python.rs didn't escape NUL.
    • Fix: one escaping pass now handles \\, ", \r and NUL, which becomes \x00 so a following digit can't form an octal escape.
    • Same bug elsewhere: a one-line literal holding a foreign span's provider name was written unescaped, so a quote in the name broke the code. It now uses the same function.
    • Other characters: every control character and several Unicode separators were tested; NUL was the only one Python rejects.

Compiler output

The NUL fix changes the compiled output only for templates whose compiled code was invalid before, or whose provider-name literal evaluated to the wrong string. The shape of the output is unchanged. An independent reviewer agreed this doesn't change the compiler's output format. The table fix is in citry_vue_compiler and doesn't change the Python-facing API.

Release note

Fixes 2 and 3 ship in citry-core, and citry pins citry-core==1.8.0. Users get them after a citry-core release and a bump of that pin. Once that pin is raised, #234's check can drop the two workarounds it carries for these bugs: skipping templates that contain NUL, and staying silent on a call inside a table.

Known limits

  • A <c-element c-is="..."> that resolves to tr inside a table still fails. The compiler only sees its alias tag, and vize offers no way to judge it by the real tag. This is recorded in docs/design/vue.md.
  • A component call inside a Vue v-for whose inputs read the loop variable fails with a bare KeyError rather than a helpful message. This is filed separately.

Evidence

  • Rust: cargo fmt, clippy and cargo test pass for citry_template_parser and citry_vue_compiler. The other crates' cargo phases weren't run locally because of disk space; CI runs them.
  • Python: the citry-core tests, the Vue tests (1,258), the landing tests and 57 browser tests pass.
  • Lint and types: ruff is clean, and mypy is clean, including with --platform linux.
  • Review: an independent review and a separate prose pass.

🤖 Generated with Claude Code

JuroOravec and others added 4 commits October 21, 2026 18:22
…235)

A NUL character anywhere in a template (text, an attribute value, an
expression) reached the generated `generate_template()` code as a raw NUL
inside a triple-quoted literal. Python refuses source code that holds a
NUL, so the template failed when Citry ran its compiled code.

The Python code writer now escapes string content in one pass: backslash,
double quote, carriage return, and NUL (as `\x00`, so a following digit
cannot extend an octal escape). Every other character survives a
triple-quoted literal unchanged; a test round-trips all control
characters and a few Unicode line and format characters.

One-line `"..."` literals (SafeString) go through the same function. The
compiler builds them from checked names, so their output is unchanged,
but a foreign span's provider name reaches the parser checked only for
being non-empty, and a quote in it ended the literal early.

The literal syntax and node shapes stay the same; only templates whose
compiled code was invalid (or, for a provider name, evaluated to the
wrong string) produce different output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…235)

In a component that uses Vue, a component call inside a <table>,
<tbody>, <thead>, <tfoot>, <tr>, or <colgroup> failed at render with
"Foster parenting moved this element before the nearest open table".

The native Vue compiler first parses the generated template with Vize's
default parser options, which read the tag Citry writes for a call (such
as <citry-row-1a2b>, or the <component> loop for a run of calls) as an
HTML element, so Vize's table rules moved it out of the table. The tag
never reaches the browser, and the compile stage already read it as a
component. That parse, and the hydration plan's parse of the same text,
now read the declared call tags and <component> as components through
`parse_generated_template`. Every other tag keeps the default reading,
so an authored <div> or custom element directly in a table still fails.
Whether the child's own root fits is still decided by the server's
hydration check.

A <c-element> whose c-is resolves to a table part still fails inside a
table: the compiler sees only its citry-dynamic-* alias. Recorded in
docs/design/vue.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The landing editor demo put <c-MemberChip> inside a Vue v-for, so its
c-name read Vue's loop variable on the server and the demo failed to
render. It now repeats the chips with <c-for> over a Python value and
passes each member's data as Python inputs, as the docs recommend, and
passes the parent's `compact` prop to each chip with :compact. The
demo's three deliberate mistakes stay.

The hover annotations follow the new source. A test renders the demo
with its marked unknown template variable supplied, so a demo that
crashes at render fails the docs tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec changed the base branch from main to benchmarks/errors-citry-fastapi October 21, 2026 16:37
@JuroOravec
JuroOravec added this pull request to stack #219 October 21, 2026 16:38
Base automatically changed from benchmarks/errors-citry-fastapi to main October 21, 2026 17:20
@JuroOravec
JuroOravec merged commit b9b1d8c into main Oct 22, 2026
32 checks passed
@JuroOravec
JuroOravec deleted the fix/render-bugs-235 branch October 22, 2026 07:23
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.

Three render bugs found while adding the Vue compile check (#234)

1 participant