Skip to content

fix(metadata-protocol): updateMany classifies an id-less row as a caller error, matching batchData (#5100) - #5200

Merged
os-zhuang merged 1 commit into
mainfrom
claude/updatemany-hooks-nonexistent-id-p6pxb8
Aug 4, 2026
Merged

fix(metadata-protocol): updateMany classifies an id-less row as a caller error, matching batchData (#5100)#5200
os-zhuang merged 1 commit into
mainfrom
claude/updatemany-hooks-nonexistent-id-p6pxb8

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Fixes #5100

维护者已拍板补齐守卫,裁定记录在 #5100 的裁定评论。protocol.ts 已知的最后一处 by-id 写面口径漂移(#4435#5088#5099 同族),关掉它即关掉整类。

问题

runUpdateManyLooprunBatchDataLoop update 分支那道 !record.id 守卫(#4793)。同一个没有 id 的行,两个 by-id update 写面给两种分类:

写面 分类
batchData update 分支 VALIDATION_FAILED / 400(Record id is required for update
updateMany(修前) 落进 #5088 存在性探针,RECORD_NOT_FOUND / 404,消息是插值出来的 Record undefined not found in …

请求形状错误被报成数据状态错误,且未设防路径把 { id: undefined } 递进探针和写两层——这个 where 形状怎么读取决于各 driver 对 undefined 键的处理,最好情况是那个 404,其余情况不受任何约束。

当前 REST 打不到UpdateManyRecordSchema 强制 id 必填,#3939)——但这个 dormancy 依赖的不变量写在两个包之外,protocol.ts 本地无痕迹;任何新入口(进程内调用、新传输层)都会无声地把它变 live。守卫把分布式不变量收为本地不变量。

修法

  • 循环头补同一句 if (!record.id) throw rowRequiredIdError('update')——与 batch 分支共用同一个 helper、同一分类,守卫先于任何引擎往返(探针也不再跑)。
  • 顺带把 record.data 裸递对齐为 batch 分支的 record.data || {}(同族微漂移)。
  • 可观察行为变化仅限进程内调用者:id-less 行从 404(消息含 undefined)变为 400。changeset 如实记录。

先证红再信绿

#5088 的跨面一致性测试文件里新增 [#5100] describe(2 例:单面分类断言 + 双面同答案的 #4620 对称 pin,含"引擎从未被问到"断言)。守卫缺席时:

Tests  2 failed | 15 passed (17)
AssertionError: expected 'RECORD_NOT_FOUND' to be 'VALIDATION_FAILED'   // 单面分类
AssertionError: expected 'RECORD_NOT_FOUND' to be 'VALIDATION_FAILED'   // 双面对称 pin

修复后:@objectstack/metadata-protocol 40 文件 / 348 用例全绿turbo typecheck --filter=...@objectstack/metadata-protocol 82 任务全过

备注

🤖 Generated with Claude Code

https://claude.ai/code/session_01BotUP49pqhvqGY393n2HfU


Generated by Claude Code

…ler error, matching batchData (#5100)

runUpdateManyLoop lacked the !record.id guard #4793 gave batchData's
update branch: the same malformed row answered VALIDATION_FAILED/400 on
one by-id face and RECORD_NOT_FOUND/404 ('Record undefined not found')
on the other, with the unguarded path handing { id: undefined } to the
probe and the write — a reading each driver decides for itself. The
guard fires before any engine round-trip, both faces now give one
classification (#4620), pinned by a cross-face parity test. record.data
handling aligned to the batch branch's || {} in passing.

Dormant over REST (UpdateManyRecordSchema requires id, #3939); the
change is observable only to in-process protocol callers.

Proven red-first: both new cases fail unguarded (RECORD_NOT_FOUND where
VALIDATION_FAILED is asserted). After: metadata-protocol 348 tests,
typecheck across 82 dependent tasks all green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BotUP49pqhvqGY393n2HfU
@vercel

vercel Bot commented Aug 4, 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 Aug 4, 2026 8:57am

Request Review

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

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata-protocol.

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

  • content/docs/concepts/metadata-lifecycle.mdx (via @objectstack/metadata-protocol)
  • content/docs/kernel/services-checklist.mdx (via @objectstack/metadata-protocol)
  • content/docs/releases/v9.mdx (via @objectstack/metadata-protocol)

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.

@os-zhuang
os-zhuang marked this pull request as ready for review August 4, 2026 10:46
@os-zhuang
os-zhuang added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit 38f53a0 Aug 4, 2026
24 checks passed
@os-zhuang
os-zhuang deleted the claude/updatemany-hooks-nonexistent-id-p6pxb8 branch August 4, 2026 10:52
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

2 participants