Skip to content

fix(rest): give the bare 501 exits a machine code — NOT_IMPLEMENTED (#4067) - #4068

Merged
os-zhuang merged 1 commit into
mainfrom
claude/cross-object-batch-error-envelopes
Jul 30, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/cross-object-batch-error-envelopes

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Closes #4067。批量 API 契约一致性清扫线(承 #3897 / #3933 / #3939)的收官项 —— 补齐 REST 层最后几处裸串 501。

背景

REST 层的错误出口绝大多数已带类型化 code(VALIDATION_FAILED / BATCH_NOT_ATOMIC / BATCH_TOO_LARGE / PERMISSION_DENIED),clone 与 search 的 501 也已是 { error, code: 'NOT_IMPLEMENTED' }。但四处 501 出口仍返回裸 { error: '<string>' },客户端只能按文案区分:

位置 出口
rest-server.ts 跨对象批量 POST {basePath}/batch 运行时无 transaction() —— 该路由最后一处未类型化的出口;其余(BATCH_NOT_ATOMIC、VALIDATION_FAILED、enforceBatchSize 的 BATCH_TOO_LARGE)都已在 #3897 / #3933 / #3939 里类型化
saveMetaItem ×2 'Save operation not supported by protocol implementation'
UI View 解析 'UI View resolution not supported by protocol implementation'

跨对象批量那处即本轮待办的 #3;另三处是同形的 501 NOT_IMPLEMENTED 裸串,顺手一起收(与 #2 折进 validateOnly PR 同理),使"每个 501 都带它兄弟早已有的机器码"这一致性真正闭合。

改动

四处 501 一律补 code: 'NOT_IMPLEMENTED',对齐 clone/search 的扁平信封 { error: '<message>', code }。纯新增字段 —— error 文案与 status 均不变,现有客户端不受影响,新客户端可按 code 分支。

扩展跨对象批量路由的 501 测试:从只断言 status(501) 增加断言 res.body.code === 'NOT_IMPLEMENTED'。

测试

  • @objectstack/rest 全绿:35 文件 / 505 测试(含扩展后的批量 501 断言)。
  • 现有其余 501 测试只断言 status,新增 code 不影响。
  • changeset:@objectstack/rest patch(additive)。

审阅指引

改动集中在 packages/rest/src/rest-server.ts 的四处 res.status(501).json(...),以及 rest-batch-endpoint.test.ts 的一条断言。

🤖 Generated with Claude Code

https://claude.ai/code/session_01TzLE9cw4gZKNyPN2ZP4iTt


Generated by Claude Code

…4067)

Most REST error exits already carry a typed `code`, and the clone / search 501s
answer `{ error, code: 'NOT_IMPLEMENTED' }`. Four 501 exits still returned a
bare `{ error: '<string>' }`, so a client could only key on the prose:

- the cross-object transactional batch route (POST {basePath}/batch) when the
  runtime has no transaction() — the last untyped exit on that route, whose
  siblings (BATCH_NOT_ATOMIC, VALIDATION_FAILED, enforceBatchSize's
  BATCH_TOO_LARGE) were already typed by the #3897 / #3933 / #3939 line;
- the two saveMetaItem-unsupported exits;
- the UI-view-resolution-unsupported exit.

Each now carries code: 'NOT_IMPLEMENTED', matching clone / search. Additive only
(message and status unchanged), so existing clients are unaffected. Extended the
cross-object batch 501 test to assert the code.

Closes #4067.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TzLE9cw4gZKNyPN2ZP4iTt
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Jul 30, 2026 7:54am

Request Review

@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation tests tooling labels Jul 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/rest.

8 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/ai/connect-mcp.mdx (via @objectstack/rest)
  • content/docs/api/error-handling-server.mdx (via @objectstack/rest)
  • content/docs/api/index.mdx (via @objectstack/rest)
  • content/docs/plugins/index.mdx (via @objectstack/rest)
  • content/docs/plugins/packages.mdx (via @objectstack/rest)
  • content/docs/protocol/kernel/i18n-standard.mdx (via packages/rest)
  • content/docs/releases/implementation-status.mdx (via @objectstack/rest)
  • content/docs/releases/v12.mdx (via @objectstack/rest)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

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/s tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST 若干 501 出口返回裸 { error: string },缺 machine code —— 跨对象批量路由等

2 participants