fix(gate): require whitespace after select in the raw-query shape#186
Merged
Conversation
The untested-data-access gate flagged apps/app/src/routeTree.gen.ts on a route-tree regeneration PR (Site#3614). Cause: the raw `select … from` shape matched the `/membership/select-plan` route path — `\bselect\b`'s right boundary is the hyphen — with an import `from` two lines down completing the shape. A route path read as a SQL query. Require whitespace after `select`, as real `SELECT … FROM` has, so a hyphenated (or dotted, slashed) identifier no longer reads as a query. Camel/underscore identifiers (`selectPlan`, `select_plan`) never matched `\bselect\b` and are unaffected. Refs Query-Doctor/Site#3615 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Query Doctor Analysis
3 queries analyzed
0 regressed · 0 improved · 0 new · 0 removed
2 pre-existing issues
SELECT "guests"."id", "guests"."session_id", "guests"."username", "guests"."avatar_path", "guests"."color", "guests"."side", "guests"."audio_recording_path", "guests"."audio_recording_public", "gue...
indexassets(event_id, inserted_at desc)
cost 31,003,449 → 1,498 (100% reduction)SELECT * FROM guest_ip_addresses WHERE ip_address = '127.0.0.1';
indexguest_ip_addresses(ip_address)
cost 154,402 → 8 (100% reduction)
Using assumed statistics (10000000 rows/table). For better results, sync production stats.
More detail → get_ci_run({ runId: "019f86ed-7a5a-7a1a-82f1-23837447076e" }) · view run · docs
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.
Goal
Stop the
untested-data-accessCI gate from reporting false positives to users. Tracked in Query-Doctor/Site#3615 (dogfooding); the triggering PR was Site#3614, a TanStack Router route-tree regeneration.What
Before: a PR that regenerated
apps/app/src/routeTree.gen.tswas flagged as changing an untested query, listing that file under "changed data-access files with no related data-layer test". The file has no data access — it is route wiring.After: the regeneration is not flagged. A route path no longer reads as a SQL query.
How
The gate's raw-query heuristic included
/\bselect\b[\s\S]{0,300}?\bfrom\b/i.\bselect\bmatched the/membership/select-planroute path because the hyphen is a word boundary, and an importfromtwo lines down completed the shape — so a route path parsed asSELECT … FROM.The one-line fix requires whitespace after
select, as realSELECT … FROMhas:select-plan(hyphen),select.foo(dot),select/x(slash) no longer match. Camel/underscore identifiers (selectPlan,select_plan) never matched\bselect\b, so they are unaffected. Readsrc/gate/test-presence.tsfirst (the pattern), then the tests.Tests
src/gate/test-presence.test.ts:select-planroute path is not classified as data-access (the reported case);SELECT id, name FROM usersstill is — recall guard, so the tightening doesn't blind the raw-SQL shape;Full suite green (310 tests), typecheck clean.
Refs Query-Doctor/Site#3615