Skip to content

fix(rest): a refused json export answers the 400 envelope, not a truncated 200 stream - #27753

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-v7c5ae
Oct 29, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-v7c5ae

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

domain:server#3 · os-elon-musk · session_016WV4d1cSb5LKsNDntVL6VG

Fixes #27682

What changes

  • packages/rest/src/data-action-routes.ts: the json export writes its opening [ after the first findData answers, not before it. One line moved into the read loop (if (format === 'json' && firstChunk) res.write('[')), placed before the zero-row break so an empty export is still []. Nothing else in the route changes, and the import-job region (fix(rest)!: an async import job for an unregistered object is refused with 404 OBJECT_NOT_FOUND before any job is created #27711) is untouched.
  • packages/rest/src/export-json-refusal-envelope.test.ts (new): pins both halves through the real HonoHttpServer.
  • .changeset/27682-json-export-read-first.md: patch for @objectstack/rest.

Why

The first res.write commits the Hono adapter to a streaming 200. Writing [ before the first read meant a query that read refused reached the client as a 200 whose body was a lone [, while format=csv answered the 400 envelope. Triage 6504427279: the json export reads its first page before it writes any byte and answers the same envelope. A refusal on a later page is not widened here.

Verification

  • Pin, over a real SqlDriver (SQLite): ?search=x&searchFields=nope (the card's repro, 400 INVALID_FIELD) and ?search=x&searchFields=, (400 VALIDATION_ERROR) answer the same status and body for format=json as for format=csv. Ablation: with the early write restored, both json rows are red (200); restored, green.
  • Byte identity: a successful json export over one page, three pages (page=50, 120 rows) and zero rows answers exactly [ + rows joined by , + ] (or []), Content-Type: application/json; charset=utf-8, with the same number of reads. Green on the unfixed code too, so the success path did not move.
  • dispatch-gates --ran: 59 derived families, 58 run green, 1 NOT MEASURED (check:dual-build-cjs-loads, exit 3, needs a whole-tree build). pnpm lint green; @objectstack/rest typecheck and full suite green (343 files, 6702 passed) after merging main.

Out of scope finding: format=xlsx has the same early commit. Its workbook writer is created before the first read, and the card's repro answers 200 there too (measured). Not fixed or pinned here; the seat can file it.

Clause-②: no
Metadata-protocol: none

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4d1cSb5LKsNDntVL6VG

…cated 200 stream

The json export wrote its opening bracket before its first read, and the
first write commits the response to a streaming 200, so a query the read
refused reached the client as a 200 carrying a lone `[`. The bracket now
follows the first read, as csv's first byte does. A successful json export
is byte-identical.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1cSb5LKsNDntVL6VG
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 58 of 210 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 19 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from ea6a768bb187d6d57dde0deba4a289a7b3dfb206 — the merge of head fd51a665dbfa698ce3e0e43757549bf8a10c3818 into base 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin ea6a768bb187d6d57dde0deba4a289a7b3dfb206 && git checkout ea6a768bb187d6d57dde0deba4a289a7b3dfb206
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65 fd51a665dbfa698ce3e0e43757549bf8a10c3818 && git checkout -B drift-repro 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65 && git merge --no-ff fd51a665dbfa698ce3e0e43757549bf8a10c3818

node scripts/docs-audit/affected-docs.mjs --json 34dc09b68df7d37ff8f70ed0dae19fbb1700dd65

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia

Seat ACCEPT · PR #27753 · head fd51a665dbfa698ce3e0e43757549bf8a10c3818 · 2026-10-29T22:45Z

维护者速读

  • 改了什么: JSON 格式导出改成先读第一页再写响应;查询被拒时返回和 CSV 一样的 400 错误信封,不再给一个只有 [ 的截断 200。
  • 为什么改: 用户导出 JSON 时如果搜索条件有误,拿到的是坏文件、看不到错误原因。
  • 风险与回滚: 只挪了一行写入的位置;成功导出逐字节不变(单页、多页、零行都钉了测试)。回滚 = revert 本 PR。
  • 先看: packages/rest/src/data-action-routes.ts 导出循环里 [ 的位置。
  • 两分钟验证: pnpm --filter @objectstack/rest exec vitest run src/export-json-refusal-envelope.test.ts。
  • 需要你做的: 无,席位按本任期落地授权落地。

席位核对

ACCEPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

1 participant