Skip to content

fix: JSON check ranges, State token spec, and v-for variable errors (#203, #204, #240) - #247

Merged
JuroOravec merged 4 commits into
mainfrom
fix/issues-203-204-240
Oct 22, 2026
Merged

JuroOravec merged 4 commits into
mainfrom
fix/issues-203-204-240

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Fixes three issues, one commit each.

#204: when a rejected State token answers stale_state

The server's behavior is intentional. A token whose signature no current secret matches, but whose payload still reads cleanly, looks exactly like one signed with a rotated-out secret, so it answers 409 stale_state. The Events spec now matches the code and states the order in which the server checks a token (malformed → 403; expired, unknown signature, or server-held State gone → 409; another component class → 403; State that no longer fits → 409). New tests lock that order for signed and server-held tokens. Server behavior is unchanged.

#203: citry check JSON ranges

Every range in the JSON report now counts lines and columns from 0, with columns in UTF-16 units as in the Language Server Protocol, and line breaks may be CR LF, CR, or LF. Each range says which text it counts in: "source_kind": "file" | "inline" (the same name and values as ComponentGraphLocation.source_kind). An i18n catalog error now points into the messages_file it came from, and a JsData origin names its Python file. Building a report fails if a range has no source_kind. The error benchmark's Citry parser is updated to the new numbering. A "JSON report" section in the CLI docs describes it.

#240: a server expression that reads a Vue v-for variable

Reading a v-for variable from server-side code ({{ }}, c-* attributes, c-bind, <c-if>/<c-for> conditions) now raises VueLoopVariableError (still a KeyError). The message names the tag, template, and line, says the variable exists only in the browser, and suggests <c-for each="member in members"> or the Vue form. Other KeyErrors are unchanged. A destructured v-for and #c-key on a plain element still raise a plain KeyError. Troubleshooting docs have a new "Loop variable missing" section.

Checks

ruff, mypy (also with --platform linux), the validators, and the docs build check are clean. Locally, pytest failures come only from the environment (the published citry-core 1.8.0 is missing unreleased Rust changes, plus tzdata and pygments version drift); CI is authoritative.

Note for #243: once it's rebased on this, _unknown_inject_key_findings needs _counted_in(..., "file"). #242 will have a text conflict on the JsData origin line.

Closes #203. Closes #204. Closes #240.

🤖 Generated with Claude Code

JuroOravec and others added 3 commits October 22, 2026 12:16
The Events spec said a token that fails signature verification answers
invalid_state 403. The server answers stale_state 409 when the token is
still readable, because a changed signature looks exactly like an honest
token signed with a secret the server has since removed. The spec now
states that rule and the order the server checks a token in: a missing
or unreadable token (403), then an expired token, a signature no current
secret matches, or server-held State that is gone (409), then a token
minted for another component class (403), then State that no longer fits
the component's State class (409). The server behavior is unchanged.

Token tests now tie a changed-signature token to the stale_state example
result, and pin the order: a stale signed or server-held token for
another class answers 409.

Fixes #204

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it counts in (#203)

`citry check --format json` numbered template syntax errors, unknown
variables, unknown components, and i18n catalog errors from 1, and every
other rule from 0. A JsData field's column counted UTF-8 bytes. Every
range now comes from its byte offsets through one helper, so lines and
columns count from 0 with columns in UTF-16 code units, as the Language
Server Protocol counts them. Lines end only at CR LF, CR, and LF, the
way Python and editors end them, and byte offsets count each line break
as one "\n", as Python reads a text file.

Each range now carries `source_kind`, the name and values
ComponentGraphLocation already uses: "file" when it counts in the file
the origin names, "inline" when it counts in a string written on a class,
such as `template`. A report rejects a finding that has a range but no
`source_kind`, so a new rule cannot ship an ambiguous range. A JsData
field's origin now names its Python file, like the other findings about
Python code. An i18n catalog error is placed in the text the compiler
read, so a `messages_file` error counts in that file.

The error benchmark's citry parser read inline template lines as counted
from 1; it now adds 1 for the 0-based line, and maps a finding whose
origin is a template, JavaScript, CSS, or messages file to that file.

Fixes #203

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ble (#240)

A component input such as `c-name="member.name"` inside
`<li v-for="member in members">` failed at render with a KeyError that
only named `member`, printed as one escaped line. Citry evaluates the
input on the server, and `member` exists only in the browser.

When safe_eval reports a failed lookup of a name the server lacks, the
render error helper checks whether the innermost Vue v-for around the
failing node declares that name. If so it raises a VueLoopVariableError
(still a KeyError) that names the tag, the template, and the line, says
why the variable is missing, and gives the fix: repeat on the server with
`<c-for each="member in members">` (or, when the server has no such list,
a `<c-for>` over a list from template_data()). For `{{ }}`, `c-*`
attributes, `<c-if>`, and `<c-for>` it also offers the Vue form
(`v-text`, a `:` binding, `v-if`, a nested `v-for`), unless a component
call sits between the loop and the expression, which the Vue compiler
rejects inside a v-for. Any other KeyError, including a different
missing name in the same expression, is left as it is. `<c-if>` and
`<c-for>` conditions that read the loop variable also get a template
snippet. The troubleshooting guide gains a section for the error.

Fixes #240

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec changed the base branch from main to docs/landing-benchmark-charts October 22, 2026 10:36
@JuroOravec
JuroOravec added this pull request to stack #219 October 22, 2026 10:36
Main brought two checks whose findings carry ranges: the CSS class rules
(#242) and the unknown inject key rule (#243). Both already counted from
0 in UTF-16 units through `_byte_offset_coordinates`, but neither said
which text it counts in, so the report rejected them. The CSS class
findings are now built with `_ranged_finding` from their template source,
and the inject key findings are marked as counting in the component's
Python file. Their tests now also check `source_kind`; no expected
position changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from docs/landing-benchmark-charts to main October 22, 2026 11:05
@JuroOravec
JuroOravec merged commit 1e07f8a into main Oct 22, 2026
17 of 26 checks passed
@JuroOravec
JuroOravec deleted the fix/issues-203-204-240 branch October 22, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant