Skip to content

Reject invalid notebook insert cell kinds#273

Open
jlewi wants to merge 2 commits into
mainfrom
codex/fail-closed-notebook-cell-kind
Open

Reject invalid notebook insert cell kinds#273
jlewi wants to merge 2 commits into
mainfrom
codex/fail-closed-notebook-cell-kind

Conversation

@jlewi

@jlewi jlewi commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • validate every notebooks.update insert cell kind before mutating the notebook
  • reject values other than code or markup with an actionable error
  • add a regression test proving a later invalid cell prevents earlier valid cells from being partially inserted

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

  • pnpm -C app exec vitest run src/lib/runtime/runmeConsole.test.ts
  • runme run build test
  • Prettier check for both changed files

The repository-wide app typecheck was also attempted and remains red on unrelated existing errors outside this change.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +402 to +404
for (const [index, spec] of specs.entries()) {
const kind = (spec as { kind?: unknown } | null)?.kind
if (kind !== 'code' && kind !== 'markup') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant