fix(react): an invalid query update is rejected, not fatal - #553
Merged
Conversation
The derivations spec deferred this as a different design question. Measuring showed it is smaller: only the query PROP on update is fatal (rows 3 to 0, bytes 8702 to 0). Both grid.setQuery paths are already correct — controlled reports intent and stops, uncontrolled throws catchably to its caller — so they get pins, not changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
An invalid `query` arriving on the prop after mount threw out of the layout effect that reconciles it, escaping the commit and unmounting the live grid (measured on 59835a4: rows 3 to 0, bytes 8702 to 0). It is now a rejected write — the row model keeps the query it already had, the grid stays interactive, and the fault is reported once per distinct fault via warnOnce. The guard lives inside `applyQuery`, not around its call sites, because there are two: the closure runs synchronously when no derivations transition is pending and from a `.then()` callback when one is. Only the synchronous path showed the fatal signature; both are covered and both are tested. The mechanism itself is extracted as `reportRejectedWrite` and shared with the derivations guard from #550, which was byte-identical in executable logic — the name check, the rethrow, the cast, the three field reads and the warnOnce key construction — so a fix to one no longer misses the other. It is parameterized on a SET of accepted error names rather than one literal, because `setRows`, the remaining unguarded call on this seam, would need two. Two behaviours that were already correct are pinned, not changed: an invalid query at mount still throws, and an uncontrolled `grid.setQuery` still throws synchronously to its caller. #550's comment claiming an open unguarded-`setQuery` hazard is now false and is rewritten in both places it appears; the error-name pin's header and triage table are rescoped from one guard to two. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Vercel preview readyPreview: https://pretable-70c1zi5o8-cacheplane.vercel.app Updated automatically by the |
This was referenced Aug 31, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
An invalid
queryarriving on the prop after mount used to destroy a live grid. The compiler'sCompiledQueryValidationErrorwas thrown synchronously out of the same layout effect that already guards derivations, so it escaped the commit and React unmounted the subtree — measured as rows 3 → 0, container 8702 → 0 bytes.It is now a rejected write: the row model keeps the query it already had, the grid stays interactive and keeps painting the rows that query selected, and a later valid query still lands.
This is the sibling of #550. Spec: the 2026-08-31 amendment in
docs/superpowers/specs/2026-08-27-invalid-derivations-are-rejected-design.md. Plan:docs/superpowers/plans/2026-08-31-invalid-query-is-rejected.md.Measuring shrank the job, and corrected me twice
The follow-up assumed query rejection was a bigger design question than derivations, because a query is consumer-controlled state with an
onQueryChangeround trip. Probing all four doors showed only one is broken:queryprop on updategrid.setQuerywhile controlledonQueryChangeand stopgrid.setQuerywhile uncontrolledI first recorded the imperative door as "silently swallows the query" — a second defect. It isn't: my probe passed both
queryandonQueryChange, so the surface was controlled, wheresetQuerydeliberately doesn't apply. Re-measuring uncontrolled showed a catchable throw that destroys nothing.That also dissolved the design question.
onQueryChangereports engine-originated changes, so a refused consumer prop must not fire it — pinned, not debated.Also in here
The shared mechanism is extracted. The two guards had byte-identical executable logic.
reportRejectedWrite(module-private, so no API surface) now owns the name check, rethrow, field reads with fallbacks, and the index-strippedwarnOncekey. It is parameterized on a set of accepted error names becausesetRows— the remaining unguarded call on this seam — would need two:remapSetRowsErrorpassesCompiledQueryValidationErrorthrough unchanged but wraps other faults asPretableSetRowsExecutionError. That is filed, not built.The extraction's payoff is visible as data: mutations to the shared name set and to the key now red both test files, which is exactly the "fix one, miss the other" failure mode.
What the reviews caught
setQuerythrow was "the pre-existing unguarded hazard, filed separately" — true when written, invalidated by this very change. Found by checking a comment the diff never touched. The implementer then found the same false claim in a second place no reviewer had named.query-rejectedwarning that its fixture cannot produce. Proved by mutation — forcing the path failed exactly one test and every warn-count assertion stayed green.The chained
applyQuerypath — where a throw is an unhandled rejection rather than an unmount — was flagged in the plan as possibly untestable. It is testable, and the test proves which path it took: instrumentation confirms it takes.then(), and its assertion cannot pass on the synchronous path.Verification
The probe deliberately baselines on a narrowing query so the surviving count cannot be confused with a cleared one, and it was mutation-checked: disarming the guard makes both probe cases fail.
🤖 Generated with Claude Code