Reject invalid notebook insert cell kinds#273
Conversation
Signed-off-by: Jeremy lewi <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58ac646b91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const [index, spec] of specs.entries()) { | ||
| const kind = (spec as { kind?: unknown } | null)?.kind | ||
| if (kind !== 'code' && kind !== 'markup') { |
There was a problem hiding this comment.
Validate insert kinds before applying any operation
When a notebooks.update request contains an earlier valid mutation followed by a later insert with an invalid kind (for example operations: [update, insert(kind: "markdown")]), this validation only runs once the insert operation is reached, after the earlier operation has already mutated the notebook in the update loop. The API then rejects but leaves a partial change behind, which defeats the new “reject before mutating” behavior for multi-operation updates; pre-validate all insert specs before applying any operation or roll back the whole update on this error.
Useful? React with 👍 / 👎.
Signed-off-by: Jeremy lewi <[email protected]>
Summary
Why
The TypeScript type is not enforced for JavaScript executed through AppKernel. Previously, any value other than markup silently fell through to a code cell, so kind: markdown created the wrong cell type instead of failing.
Validation
The repository-wide app typecheck was also attempted and remains red on unrelated existing errors outside this change.