32 lines
1.4 KiB
Markdown
32 lines
1.4 KiB
Markdown
# 5-21 [done] page.body.save 对非法 editorDocument 不能静默回退
|
||||
|
|
|
|||
|
|
## 级别
|
|||
|
|
|
|||
|
|
P1 / 05-editor-mainline 主线迁移缺陷。
|
|||
|
|
|
|||
|
|
## 现象
|
|||
|
|
|
|||
|
|
`page.body.save` 在保存时会同时携带 `editorDocument`、`tiptapDocument` 和 legacy `content`。
|
|||
|
|
当 `editorDocument` 字段存在但结构非法时,原实现会静默回退到 `tiptapDocument` 或 `content`,把原生块快照损坏隐藏掉。
|
|||
|
|
|
|||
|
|
## 根因
|
|||
|
|
|
|||
|
|
`normalize_save_editor_document(...)` 之前只在 `serde_json::from_value::<EditorBlockDocument>` 成功时才使用 `editorDocument`,失败后会继续尝试 `tiptapDocument`,最后再回退 `legacy content`。
|
|||
|
|
|
|||
|
|
## 修复
|
|||
|
|
|
|||
|
|
- `editorDocument` 一旦存在就必须可解析。
|
|||
|
|
- `editorDocument` 无法反序列化时,直接返回 validation error,不再回退到 `tiptapDocument` 或 `content`。
|
|||
|
|
- 现有“合法 editorDocument 优先于其他来源”语义保持不变。
|
|||
|
|
|
|||
|
|
## 验证
|
|||
|
|
|
|||
|
|
- RED:`cargo test --manifest-path rust/Cargo.toml -p bridge-runtime documents_save_command_plan_rejects_unparseable_editor_document_instead_of_falling_back -- --nocapture`
|
|||
|
|
- 旧实现失败,证明原先会静默回退。
|
|||
|
|
- GREEN:`cargo test --manifest-path rust/Cargo.toml -p bridge-runtime documents_save_command_plan -- --nocapture`
|
|||
|
|
- 12 passed。
|
|||
|
|
|
|||
|
|
## 剩余边界
|
|||
|
|
|
|||
|
|
这次修复只收紧非法 `editorDocument` 的失败语义,不改变合法 `editorDocument` / `tiptapDocument` 的既有优先级顺序。
|