feat(protocol): surface silently-stripped write fields on the update response (#3431)#3440
Draft
os-zhuang wants to merge 1 commit into
Draft
feat(protocol): surface silently-stripped write fields on the update response (#3431)#3440os-zhuang wants to merge 1 commit into
os-zhuang wants to merge 1 commit into
Conversation
…response (#3431) PATCH /data returned 200 + record even when the data layer legally stripped part of the caller's write (static readonly #2948 / readonlyWhen #3042). The strip is correct semantics but was silent on this surface — the only signal lived in a server WARN log. This reuses the engine's onFieldsDropped channel (#3407/#3413) to report it, one surface over. - spec: UpdateDataResponseSchema gains optional droppedFields (DroppedFieldsEvent[]), present only when >=1 field dropped; purely additive, success unchanged - metadata-protocol: updateData threads onFieldsDropped and attaches collected events to its response envelope, which the REST PATCH handler passes through createData/POST is not wired: insert is readonly-exempt so produces no events. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HaofCZbsPTHE2oJedvKd77
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 3 package(s): 108 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3431.
问题
PATCH /data/:object/:id返回200 + record,即使数据层把调用方写入的部分字段合法剥离 —— 静态readonly(#2948)或被 TRUEreadonlyWhen(#3042)锁住的字段。剥离是正确语义,但在 REST 这个面上沉默:唯一信号躺在服务端 WARN 日志里,API 客户端的部分写入「就是没保存」,且无从察觉。这正是 #3407/#3413 为流程引擎关掉的同一个缺口,挪到 REST 这一个面 —— 复用引擎已有的
onFieldsDropped可观测性通道,不新造机制。方案
调研发现
updateData的返回本就是信封{ object, id, record },所以加一个字段是纯增量、非破坏 —— 无需我在 issue 里提的「响应头 vs 信封」取舍(信封已存在)。@objectstack/spec,契约)—UpdateDataResponseSchema新增可选droppedFields:DroppedFieldsEvent[]({ object, fields, reason: 'readonly' | 'readonly_when' }),仅当剥离 ≥1 字段时出现。复用 feat(automation): update_record/create_record 步骤对被静默剥离的写入字段挂 warning(#3407) #3413 落地的DroppedFieldsEventSchema(PD Remove explicit pnpm version from workflows to fix version conflict #7 单一 Zod 源)。既有客户端读.record不受影响;success语义不变(剥离被暴露、不升级为失败)。updateData把onFieldsDropped收集器透传进engine.update,把收集到的事件挂到返回信封上;REST PATCH handler 的res.json(result)原样带出。边界 / 范围
createData/POST 不接线:insert按既有语义豁免 readonly(INSERT 可以设只读列),不产生剥离事件 —— 接线只会是 inert 代码。若将来 insert 新增静默剥离,再接。这与 feat(automation): update_record/create_record 步骤对被静默剥离的写入字段挂 warning(#3407) #3413 的诚实取舍一致(不造空通道)。isSystem: true)本就跳过 readonly 剥离,不受影响。测试
packages/objectql/src/protocol-data.test.ts新增 4 例:透传onFieldsDropped监听器 / 剥离字段结构化出现在响应且保留 record / 多趟剥离(readonly + readonlyWhen)聚合 / 无剥离时不带droppedFields键;gen:docs再生content/docs/references/api/protocol.mdx,check:docs/check:api-surface/check:spec-changes/check:upgrade-guide全部 in-sync;@objectstack/rest全链 turbo build 绿。含 changeset(spec / metadata-protocol 各 minor)。
关联
successwhen written fields are silently stripped — no observability for dropped writes (split from #3356) #3407(流程侧缺口)/ feat(automation): update_record/create_record 步骤对被静默剥离的写入字段挂 warning(#3407) #3413(数据层onFieldsDropped通道,已合并)🤖 Generated with Claude Code
https://claude.ai/code/session_01HaofCZbsPTHE2oJedvKd77
Generated by Claude Code