Repository navigation
fix(runtime)!: an analytics query that selects nothing answers 400 VALIDATION_FAILED at the entry - #35771
Conversation
…ntry with 400 VALIDATION_FAILED Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
…fusal Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
…ction pin Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 30 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 01285b342a207afc6756b0a0f13a6cd1790b4aea && git checkout 01285b342a207afc6756b0a0f13a6cd1790b4aea
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1a21ce93a2f8f95a52955380ab6f296b6ab89db4 d22928425cfe2a262b74fcce52bead222f7edc84 && git checkout -B drift-repro 1a21ce93a2f8f95a52955380ab6f296b6ab89db4 && git merge --no-ff d22928425cfe2a262b74fcce52bead222f7edc84
node scripts/docs-audit/affected-docs.mjs --json 1a21ce93a2f8f95a52955380ab6f296b6ab89db4
|
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH Seat checkL1: REWORK, one item: the declaration (L1-a, for area d7-B) at head Must fix
Read and accepted (carries over to the delta)
Generated by Claude Code |
…a narrowing, with its ADR-0087 disposition Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH Seat check (delta)L1: ACCEPT (L1-a, for area d7-B) at head
What the delta changes
Each REWORK point, closed
Gates and routing
Generated by Claude Code |
|
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7 Contract reviewServed-tier: ① Derived judgmentsRead on the tree at this head (PR #35771, card #33840, narrowing face). What is newly refused. One class of body, on Nothing else is. Case by case, against the guard (
Order. The guard is the last statement of One consequence the changeset does not name (S1). The guard runs before the engine, so inside the newly refused class the engine's own earlier refusals no longer answer. Read in Exports. ② Semver level
③ Boundary flags
④ Design judgmentThe narrowing against the published spec on Envelope: Break attempts:
Findings: S1 (should-fix) — N1 (nit) — the test pins no body with N2 (nit) — No must-fix. Implemented-by: VERDICT: PASS |
…name the prior engine refusals it supersedes Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH Seat check (delta 2)L1: ACCEPT (L1-a, for area d7-B) at head Two conditions remain:
The delta
Nit (not owed)The FROM bullet's first sentence (" Gates and routingAfter CI is green and the delta L2 PASSes on Generated by Claude Code |
|
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7 Contract reviewServed-tier: Delta review of ① Derived judgmentsNothing about what is refused has moved: the guard is unchanged. One addition to the earlier reading: S1, each FROM the banner now names, against the code:
The original FROM line (500 on PR body at this head. The BREAKING paragraph carries the same sentences and they hold as above. "20 passed" matches the file: 7 cases per door before, 3 added per door. The 速读 block still names only the 500; it is a summary and says nothing false. ② Semver levelUnchanged and still right: Check-runs on ③ Boundary flags
④ Design judgmentN1, the precedence pins. Closed. On both doors: an unknown cube with an empty projection answers the 400 at Findings: N3 (nit) — N2 from the earlier record (the No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · os-tesla · session_01L9qibvvVzM5KhCWkT5f45c 维护者速读
席位核对Seat 7: hand-off for the maintainer's approval · head
|
|
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7 Queued · 2026-11-20T11:55Z · head The maintainer account os-zhuang put this PR in the merge queue at 11:55Z, on the same head that carries L1 delta ACCEPT 7035191189 and the CONTRACT_REVIEW_TIER delta PASS 7035200811. The head has not moved, so no L2 carry is owed. |
Requested by Tesla · project thread
Fixes #33840
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — nothing under skills/ covers analytics/query projection or an empty measures
维护者速读
.claude/**lands by declared rule-change, a declared narrowing waits for the maintainer #35610 需要你在 GitHub 上点一次 Approve;之后席位自主落地。What changes
POST /api/v1/analytics/querywithmeasures: []and no dimensions passed the entry check (the schema accepts an emptymeasuresbecause a dimension-only query is legal, and it has no cross-field rule), reached the native SQL strategy, which assembledSELECT FROM "TABLE", and answered500 DATABASE_ERROR. The/analytics/sqldoor echoed the same statement as a 200.assertAnalyticsQueryBody(runtime,packages/runtime/src/domains/analytics.ts) now runs one more rule after the schema parse succeeds: a query that selects no measure, no dimension and notimeDimensionsentry carrying agranularityis refused with the existing400 VALIDATION_FAILEDand onedetails.fields[]entry{ field: 'measures', code: 'min_items' }whose message tells the caller to select at least one measure or dimension. Both/analytics/queryand/analytics/sqlcall this one function, so the/sqlecho is covered by the same guard with no extra code. The body is still forwarded untouched when it passes.What counts as a projection follows what the strategies group or aggregate by: a measure, a dimension, or a bucketed time dimension (the ObjectQL strategy turns each granularity into a group key). A time dimension with only a
dateRangeis a filter and selects nothing on its own, so it does not rescue an empty projection.No spec change, no new error code (
VALIDATION_FAILEDand themin_itemsfield code are existing catalog members). Changeset:@objectstack/runtimepatch.BREAKING (narrowing).
AnalyticsQuerySchemaadmitsmeasures: []with no minimum, so the refused body was inside the published accept set, and/analytics/sqlanswered it with a 200 before this change. Where the engine refused such a body before choosing a strategy, that refusal now becomes the same 400 atmeasures, measured on the engine at this head for both strategies and both doors: an unknown orpublic: falsecube (404 CUBE_NOT_FOUND), a cube over an object the caller may not read (403 PERMISSION_DENIED), and anorderkey naming no selected member (400 INVALID_FIELD). On a deployment the ObjectQL strategy serves,/analytics/queryanswered a 200 with one row that carries no column. DeclaredClause-②: no (narrowing), as the dataset-door twin was; the changeset carries the FROM/TO, the caller's one-line fix and the ADR-0087 dispositionnot-required (no-migration-prescription): no schema key, export, stored row or authored value moves.Read first (by risk):
packages/runtime/src/domains/analytics.ts, the newassertAnalyticsQuerySelectsSomethingand its call at the end ofassertAnalyticsQueryBody(the risk hunk: the bucketed time-dimension exemption, which keeps a granularity-only query reaching the engine).packages/runtime/src/analytics-empty-projection-refusal.test.ts(refusal and preservation pins on both doors).Two-minute check:
pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/analytics-empty-projection-refusal.test.tsshows 20 passed.Tests
New
packages/runtime/src/analytics-empty-projection-refusal.test.ts, driving the mounted routes throughdispatcher-pluginwith the harness of the sibling empty-cube test, on both/analytics/queryand/analytics/sql:{measures: []},{measures: [], dimensions: []}, and{measures: []}with a date-range-only time dimension each answer 400,error.codeVALIDATION_FAILED,error.httpStatus400, one field entry atmeasureswith codemin_items, and the service is never called;ApiErrorSchema;measuresand never reaches a stub engine that answersCUBE_NOT_FOUND/ 404 for that cube; control: the same cube with one measure reaches it and answers the 404; andwhere,orderandlimitwith an empty projection are still refused.Readings (head d8fc051 unless noted)
Test Files 2 passed (2),Tests 24 passed (24), lock VERDICT command-exit 0.pnpm --filter @objectstack/runtime testat 5aeaf59 (before the last commit, which only adds a module-top side-effect import to the new test):Test Files 633 passed (633),Tests 11669 passed | 25 skipped (11694), lock VERDICT command-exit 0.pnpm --filter @objectstack/runtime typecheckat 5aeaf59: exit 0 (tsc and check:test-typecheck OK).scripts/ablation-replace.mjsdeleted the call line, anchor 1 to 0, blob 2fa8f9336 to 614cfcb88):Tests 8 failed | 6 passed (14), the 8 being the refusal and envelope cases on both doors, the 6 the preservation cases; restore verified blob equals HEAD andgit diff HEADempty. This red run is also the door-level reproduction: without the rule the empty projection reaches the service.Test Files 1 passed (1)/Tests 20 passed (20), VERDICT command-exit 0; runtime typecheck exit 0. Ablation again (call line deleted, blob 2fa8f9336 to 614cfcb88):Tests 12 failed | 8 passed (20), the 12 being every refusal, envelope and precedence case on both doors, the 8 being the preservation cases and the 404 controls; restored to the HEAD blob withgit diff HEADempty.AnalyticsService(deleted, not committed), bodymeasures: [], onqueryandgenerateSqlunder each of the native SQL and ObjectQL strategies: unknown cube andpublic: falsecube gaveCUBE_NOT_FOUND404; a walled object gavePERMISSION_DENIED403;orderon an unselected key gaveINVALID_FIELD400; the plain empty projection gaveSELECT FROMongenerateSql, and onquerya 200 with one columnless row under the ObjectQL strategy.Acceptance notes
/analytics/sql: covered by the same guard with no extra code (both doors callassertAnalyticsQueryBody).native-sql-strategy) still builds an empty SELECT list for a caller that reaches it in-process without this door; not changed here (the card's route is the runtime door).Verification
Local gate subset
node scripts/pm/dispatch-gates.mjs --commandsderived 68 families for this diff; all 68 run locally, reconciled with--ran: "68 derived famil(ies) accounted for, 68 run, 0 NOT-MEASURED (a DERIVED zero)". Two needed a second run:check:dual-build-cjs-loadsfirst answered PREREQUISITE NOT MET (no full build yet) and then exit 0 once the type-check-debt re-measure had built the tree;check:test-source-aliaswas red on the new test (a metadata load paid inside a clocked window) and green after the module-top import fix at d8fc051.node scripts/pm/overlap-check.mjsbefore each push: VERDICT clean exit 0. CI owns the full farm.At head 806d7f5 (the changeset re-declaration):
check-adr-0087-registration --base origin/mainexit 0 ("1 declared-breaking changeset(s), each carrying an ADR-0087 disposition", BREAKING+bang+clause-②-narrowing, not-required (no-migration-prescription));check-changeset-no-major --base origin/mainexit 0 ("This diff introduces nomajorbump");check-empty-changeset,check-closing-keyword-parity,check:doc-authoring,check:nul-bytes,check:issue-citations,check:changeset-gate-self-testsexit 0. The code and test files are unchanged since d8fc051.Round 2 at d229284 (test file and changeset only): 66 of the 68 derived families run, all exit 0;
--ranreports 2 UNRUN,check:type-check-debtandcheck:dual-build-cjs-loads, which need a full-tree build this worktree does not have. Both read built output and compiled types, which this round does not change; CI runs both.Full dogfood battery (head 806d7f5)
Closure built under the lock (
pnpm --filter '@objectstack/dogfood^...' build, VERDICT command-exit 0), thenpnpm --filter @objectstack/dogfood testwith no shard and no path: VERDICT command-exit 0,Test Files 482 passed | 3 skipped (485),Tests 4094 passed | 68 skipped (4162), no failure. Not re-run at d229284:analytics.tsis unchanged since then, and round 2 changes only the pin file and the changeset text.Generated by Claude Code