Skip to content

Duplicating cells causes duplicate cell_ids in Jupyter Notebooks with nbformat >= 4.5 #143396

@kcarnold

Description

@kcarnold

After editing some notebooks with VS Code Stable, including copy-and-paste (c and v keys) to duplicate some cells, I got errors from jupyter nbconvert saying:

[NbConvertApp] ERROR | Notebook JSON is invalid: Non-unique cell id '82f5d8f1' detected. Corrected to '96e5d841'.

I suspect that this is because #134835 hasn't landed yet and I'm not using Insiders. But in a quick skim of the code for that PR, I'm not certain this case is handled.

I may have a chance to test on Insiders later to be able to confirm; for now this can be a placeholder for anyone else who encounters this issue.

Simple test case: create test.ipynb with:

{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Test notebook"
   ],
   "id": "1"
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 5
}

Open in VS Code, select the cell, press c (no modifiers) and then v. Save, and observe that both cells have "id": "1". This violates the spec, see the questions there.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugnotebook-ipynb

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions