Skip to content

analytics: an empty-string where key answers 500 DATABASE_ERROR on /analytics/query, /analytics/dataset/query and MCP query_dataset, where /data answers 400 INVALID_FIELD #35543

Description

@objectstack-fleet

qa#1 · os-justin · session_01QSeKYpxQpmErd1ixfkgbYh

Found beside the clauses of dashboards.cube-query by the milestone acceptance #35539, at 92121196 on the stock showcase. Reproduced twice by the runner and twice by its helper.

Reproduction (admin)

  • POST /api/v1/analytics/query with {"cube":"showcase_invoice","measures":["showcase_invoice.count"],"where":{"":"z"}} → 500 DATABASE_ERROR. The server log says SQLITE_ERROR … near "=": syntax error.
  • POST /api/v1/analytics/dataset/query with {"datasetName":"showcase_invoice_metrics","selection":{"measures":["invoice_count"],"runtimeFilter":{"":"z"}}} → 500.
  • MCP query_dataset with the same filter → isError, DATABASE_ERROR.
  • Control: POST /api/v1/data/showcase_invoice/query with {"where":{"":"z"}} → 400 INVALID_FIELD.

Also seen, not yet reproduced twice

  • A blank key " " answered 403 PERMISSION_DENIED.
  • A four-hop dotted path to fields that do not exist (account.a.b.c.d) answered 403, naming a synthesized alias.

Both should be 400 too.

Expected

400 INVALID_FIELD at the analytics entry for an empty or blank filter key, as /data answers. A malformed body never reaches the driver.

Not a security finding: the key is quoted as an identifier and no value reaches the statement. The same class as the empty-projection 500 (#33840), on a different key.

QA-source: #35539 · dashboards.cube-query · observed beside the clauses

Activity

  1. added
    bug
    area:reports
    on Nov 19, 2026
  2. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:server · pm:queue; rationale: area:data · Bug · Impeded (an empty-string where key answers 500 instead of a 400 refusal on three analytics doors) · rare, reproduced four times → p3 as set; kept open because a 500 hides the cause. area:reports → area:data.

  3. added
    domain:server
    pm:queue
    and removed
    area:reports
    on Nov 19, 2026
  4. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Ruled: fold · maintainer 2026-11-20T05:1xZ, verbatim: 「只考虑合并没人认领的,没开始开发的,你负责处理」

    2026-11-20T05:17Z · This card now carries a fold group. Shared mechanism: malformed input on the analytics query doors answers 500 DATABASE_ERROR instead of a 400 refusal. The cards below, unclaimed and unstarted, are closed into this one so a single claimant fixes them in one PR. Each row's source card keeps its full body; this card closes when every row below and its own ask are done. Grade stays the highest of the group.

  5. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    2026-11-20T05:33Z · Correction to the fold above: #33840 was claimed by seat 7 (os-tesla) moments before the fold, so it stays its own card and is not a row here. This card carries only its own ask.

  6. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

    Picked by card-pick.mjs --order area:data --seat repo:objectstack#8 at 2026-11-28T06:00Z: p3 close-out. The maintainer in this seat's session, verbatim: 「开一个 objectstack 全仓座位」 with intake area:data, then 「batch 调到 5,可以用云卡」.

    Claim: PM loop round 1
    Session: session_017xRBcSAaBEfQpU2yJexSJ8
    Account: sunhaolin
    Branch: claude/issue-35543-analytics-empty-where-key
    Worktree: objectstack-issue-35543
    Domain: domain:server
    Seat: repo:objectstack#8
    File surface: the analytics query entry and dataset query entry that accept where / runtimeFilter (packages/services/service-analytics/src/**, and the MCP query_dataset door only if it bypasses that entry), co-located tests, one changeset per moved package; ⛔ no packages/spec/src/** (stop on breach; explain in the report)
    Container & model: S, mode:subagent, model: opus (dispatch-gates --tier: no path-derived mandate; default tier), effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack — the analytics doors pass an empty or blank filter key to the driver, which compiles invalid SQL (500 DATABASE_ERROR) | /data answers 400 INVALID_FIELD for the same body | API and MCP callers of /analytics/query, /analytics/dataset/query and query_dataset; measured 4× by qa#1 at 92121196
    Thread-read: 7031419872
    Premise: holds per qa#1's reproduction; the dev re-measures on current main first. The fold of 7031179519 was corrected by 7031419872: this card carries only its own ask.
    Serial constraints cleared: no in-flight claim names service-analytics (check-handover.mjs --inflight, seat 3's packages/** claims aside). Textual overlap re-checked with overlap-check.mjs before every push.
    Scope this dispatch: the whole card (the two "also seen" 403s are measured and fixed only if they are the same mechanism; otherwise reported). Fixes #35543.

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 28, 2026
  8. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
    os-dev-report

    {
      "issue": 35543,
      "status": "done",
      "branch": "claude/issue-35543-analytics-empty-where-key",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38218",
      "session": "session_017xRBcSAaBEfQpU2yJexSJ8",
      "premise_still_valid": true,
      "summary": "Premise re-measured on the stock showcase at origin/main 7605e0c9c. where {\"\":\"z\"} answered 500 DATABASE_ERROR on /analytics/query, /analytics/dataset/query and MCP query_dataset (SQLITE near \"=\"), {\" \":\"z\"} answered 403 PERMISSION_DENIED on all three, and /data answered 400 INVALID_FIELD. Mechanism: every analytics gate passes an empty or blank key by (namedQueryFields skips member === '', and resolveMemberSource stands down on non-identifiers). Fix: assertWhereMemberIsFieldName at the top of the #5669 where gate (assertWhereFields), before its probe stand-downs. That gate runs on every ensureCube path and on the dataset preview path, so all three doors share it. Empty and blank keys now answer 400 INVALID_FIELD with field and param 'where', and nothing reaches the engine. Scope: whitespace-only keys only. A first, wider draft that also refused non-identifier text (foo bar) turned 8 cases of the #21156 shape-gate suite red, because that suite pins PERMISSION_DENIED/403 for a caller-named non-column where leaf in every tier, so the change was narrowed. The /data validator (metadata-protocol assertFilterFieldsExist) was not reused because the analytics where gate already reads the filter tree in cube-member vocabulary. The 4-hop 'also seen' row is a separate mechanism, reported below.",
      "tests": "At head c79abcb26: under the verify lock, `pnpm --filter @objectstack/service-analytics typecheck && ... build && ... test` gave VERDICT command-exit 0, Test Files 228 passed (228), Tests 5914 passed | 345 skipped (6259). tsc --listFiles includes the new test file (1 hit). New file src/__tests__/where-member-field-name-35543.test.ts has 12 cases: empty, blank and tab keys on each of the 3 doors assert code INVALID_FIELD, status 400, field and param where, plus no engine statement; an empty key under $or; amount + 1 keeps 403 (the #21156 boundary); and a CONTROL {status:'paid'} that resolves on all 3 doors. Ablation via scripts/ablation-replace.mjs --delete of the gate call (anchor x1 -> x0, restore blob == HEAD d89850c3086d, git diff HEAD empty): 10 failed | 1 passed (the control passed). The tests import src directly, so no dist leg was needed. Live re-measure after a rebuild on the stock showcase: empty and blank keys on all three doors answer 400 INVALID_FIELD (MCP isError with status 400), CONTROL status:paid answers 200 on all three, and /data is unchanged at 400.",
      "gates": "Derived at c79abcb26 via `dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` (3 paths vs merge base 7605e0c9c): 71 families. 69 exit 0. NOT MEASURED, exit 3 prerequisite not met: check:dual-build-cjs-loads (needs a full workspace build: studio, client-react and scenarios dist absent) and check:type-check-debt (its --re-measure closure build got a queue-timeout on the verify lock behind a 50-minute dogfood holder). `--ran` with exit codes: '71 derived famil(ies) accounted for, 69 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)'. overlap-check before each push: VERDICT clean exit 0. CI check-runs on c79abcb26 were queued or in_progress at report time (Type Check workspace/source/consumer/debt ledger, Lint ESLint plus scoped families, Check Changeset, PR-body guards, Governed Surface Queue Guard, Check PR Size); none had concluded.",
      "dogfood_battery": "n/a: no `!` in the PR title and no (narrowing) arm (Clause-②: no)",
      "mcp_calls": "0",
      "api_writes": "3: git push of the branch (probe plus 2 commits, not REST); pr_create via the fleet-write relay (POST /repos/objectstack-ai/objectstack/dispatches, which executes POST /pulls and POST /issues/38218/assignees); os-dev-report comment via post-stamped.mjs (POST /issues/35543/comments)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "class: a · reach: POST /api/v1/analytics/query {\"cube\":\"showcase_invoice\",\"measures\":[\"showcase_invoice.count\"],\"where\":{\"account.a.b.c.d\":\"z\"}} gives 403 PERMISSION_DENIED 'reading \"account__a\" is not permitted for this user' (admin, stock showcase, both before and after this PR), while the 2-hop account.nope gives 400 INVALID_FIELD naming showcase_account. A multi-hop path whose second hop is not a field reaches the field-read gate as a synthesized join alias instead of the relationship-column existence refusal · dedupe words: analytics multi-hop relationship path where 403 synthesized alias account__a",
        "carrier: none · noted, not filed: a where key that is text but no column reference (foo bar) answers 403 by the #21156 shape gate where /data answers 400; that verdict is pinned in every tier and stays as designed",
        "carrier: none · noted, not filed: /data's empty-key INVALID_FIELD envelope omits `field` (the blank key carries field ' ')"
      ],
      "deviations": "The dev server was booted with `pnpm --filter @objectstack/example-showcase dev -- --fresh -p 38543` rather than `pnpm dev`, because check-dev-prereqs requires the whole workspace built (38 of 110 dist entries missing) and only the showcase closure was built. The server was torn down after measuring. The first closure build passed --concurrency=2 through to the package scripts (exit 2), and the rerun used --workspace-concurrency=2.",
      "files_changed": [
        "packages/services/service-analytics/src/analytics-service.ts",
        "packages/services/service-analytics/src/__tests__/where-member-field-name-35543.test.ts",
        ".changeset/35543-analytics-where-key-names-no-field.md"
      ]
    }

    Generated by Claude Code

  9. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
    os-dev-report

    {
      "issue": 35543,
      "delta_of": 7236169796,
      "status": "done",
      "branch": "claude/issue-35543-analytics-empty-where-key",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38218",
      "session": "session_017xRBcVgQPLb4gAUQrngR45",
      "premise_still_valid": true,
      "summary": "L1 prose round, head c79abcb2 confirmed before work, pushed 45e72db1 (one commit, prose only). Changeset: the title now reads 'an empty or blank `where` key answers 400 INVALID_FIELD on all three analytics doors'. The body now says an empty key gave 500 DATABASE_ERROR and a blank or whitespace-only key (`\" \"`, a tab) gave 403 PERMISSION_DENIED, and that both now give 400 INVALID_FIELD on the three doors. It also says text that is no column reference (`amount + 1`, `foo bar`) is unchanged and still gets the #21156 403. Removed: the 'key with a space in it (\"foo bar\") ... All of them now answer 400' claim, the identifier/relationship-path rule sentence, and the cube-declared-member sentence, which was not about empty keys. Clause-② and Metadata-protocol lines kept. Test header: it claimed 'a `where` key that names no field is refused'. It now names empty or blank (whitespace-only) keys and says non-identifier text keeps the #21156 403. The changeset was added in this PR and is not on main, so this is not a DELIBERATE CORRECTION of a released note.",
      "tests": "No code or test bodies changed (the test-file diff is the header comment only: +4/-2 lines). Not re-run this round; the c79abcb2 package run (Tests 5914 passed | 345 skipped) stands for the code. The changeset's 'a tab' claim is backed by the existing tab-only-key case on each door; `member.trim() !== ''` (analytics-service.ts:466) treats a tab as blank.",
      "gates": "check-nul-bytes.mjs exit 0. overlap-check.mjs --branch=HEAD (after git fetch origin main): VERDICT clean exit 0, merges cleanly with origin/main e42520c67b and #38218. CI on 45e72db1 not yet concluded at report time; Check Changeset reads the PR body, whose declaration lines are unchanged.",
      "dogfood_battery": "n/a: no `!` in the PR title and no (narrowing) arm (Clause-②: no)",
      "pr_body_patch": "none. The PR body already matches the tree: 'What changes' says only an empty key gave 500 and a blank key (`\" \"`) gave 403, that 'Both now answer `400 INVALID_FIELD`', and it has a 'Deliberately narrow: only whitespace-only keys' paragraph that keeps `amount + 1` / `foo bar` at 403. Acceptance notes repeat that foo bar stays 403. The PR title ('an empty or blank where key answers 400 INVALID_FIELD on all three analytics doors') is also accurate. The only stale text is 'Package run at c79abcb26' and 'Gates at `c79abcb26`' in Verification, which name the measured head truthfully and need no edit for this prose-only commit.",
      "mcp_calls": "0",
      "api_writes": "2: git push of the branch (c79abcb2..45e72db1, not REST); this delta comment via post-stamped.mjs (POST /issues/35543/comments)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "deviations": "The primary checkout's edit guard refused the edit, so the edit was made in a detached worktree ../objectstack-35543 at c79abcb2 and pushed as HEAD:refs/heads/claude/issue-35543-analytics-empty-where-key. No pnpm install was run there because the change is prose only.",
      "files_changed": [
        ".changeset/35543-analytics-where-key-names-no-field.md",
        "packages/services/service-analytics/src/__tests__/where-member-field-name-35543.test.ts"
      ]
    }

    Generated by Claude Code

  10. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

    Closed by PR #38218 (merged, Fixes #35543) · 2026-11-28T11:21Z. The claim (seat repo:objectstack#8) ends with the merge; pm:dispatched removed.

  11. removed
    pm:dispatched
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:databugdomain:serverpriority:p3

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions