A schema's {param} names are never checked against the page that has to fill them #36
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Split out of #31 (review comment on
c62d5b6), where the confirm-phrase case was fixed on its own. This is the general version.What is missing
A schema page declares its params in its own path —
stack/{project}— and then interpolates{param}into a dozen other strings: the pagetitle, every blocksource,parent.page, an action'spath/page/open/when.source, a form'ssubmit.pathandsuccessPage, a livetopic.packages/shell/src/schema/resolve.tssubstitutes""for a name the page does not have, and that is the whole error handling.packages/server/src/modules/ui-schema.tsvalidates plenty — that a page path is relative, that paths are well-formed and their percent escapes are, that page paths are unique, that a root page exists, that an action has exactly one ofpath/page/open— but never that a{name}appearing in one of those strings is a name the page can supply. A module can shipsource: "/stack/{proejct}"and nothing anywhere says so.Why it matters unevenly
The failure mode depends on where the typo lands, and only some of them are loud:
source, actionpath, formsubmit.pathparent.page, actionpage,successPagetitletopicconfirmPhraseThe
confirmPhraseone is fixed because a vanishing safety gate could not wait. The rest are still one typo from a bug whose cause is invisible at the point where it hurts.Where the check belongs
In
ui-schema.ts, as a page-level refinement — not in the web renderer.ctx.ui.registeris validated once, server-side, and every client renders what survives that: the web schema renderer, the Android app, anything later. A check in the renderer fixes one surface and leaves the others believing the schema.Shape of it: collect
{name}from the page's own path, then walk every interpolated string on that page and require each placeholder to be in that set.Two things it must not flag:
list.link = { page, params }— those values are data paths resolved against the row, not placeholders (ui-schema.ts:94), so the target page's params come from the row and not from the current page.Open question worth deciding rather than defaulting: refuse or warn? A validation error disables the module, which is the existing contract for a malformed schema and catches this before it ships. That is my preference, but it turns a page-title typo into a dead module, so it is a real call. A middle option is refusing only where the failure is silent (
topic,confirmPhrase) and logging the rest — at the cost of a rule nobody can remember.Also worth having
A test per failure mode, since the point of the check is that these are currently invisible.
packages/server/tests/ui_schema_test.tsis the home.