notebook: Notebook validation failed: Non-unique cell id

I have recently started receiving this popup error frequently when saving notebooks:

Title: Notebook validation failed

The save operation succeeded, but the notebook does not appear to be valid. The validation error was:
-------------------------
Notebook validation failed: Non-unique cell id 'waiting-opening' detected. Corrected to 'noted-romania'.:
"<UNKNOWN>"

It does not occur in new notebooks, but seems to be triggered after copying and pasting cells from other notebooks. But it is now occurring frequently on two different systems, editing different sets of notebooks. Once it appears within a notebook, it reappears on every subsequent save, with the same ‘non-unique cell id’ detected, but a different ‘corrected to <id>’ value.

I’ve attached the full output of conda list, but the versions of some particularly relevant packages are:

jupyter 1.0.0 py37h03978a9_6 conda-forge jupyter_client 6.1.11 pyhd8ed1ab_1 conda-forge jupyter_console 6.2.0 py_0 conda-forge jupyter_contrib_core 0.3.3 py_2 conda-forge jupyter_contrib_nbextensions 0.5.1 py37hc8dfbb8_1 conda-forge jupyter_core 4.7.1 py37h03978a9_0 conda-forge jupyter_highlight_selected_word 0.2.0 py37h03978a9_1002 conda-forge jupyter_latex_envs 1.4.6 py37hc8dfbb8_1001 conda-forge jupyter_nbextensions_configurator 0.4.1 py37h03978a9_2 conda-forge jupyterlab_widgets 1.0.0 pyhd8ed1ab_1 conda-forge nbconvert 5.6.1 py37hc8dfbb8_1 conda-forge nbformat 5.1.2 pyhd8ed1ab_1 conda-forge notebook 6.2.0 py37h03978a9_0 conda-forge

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 6
  • Comments: 49 (4 by maintainers)

Most upvoted comments

Same thing happened to me and I found the solution. First select all the cells in the Jupyter Notebook, then press the “cut/scissors” button (don’t panic, at this point your Notebook will be empty), and finally press the “paste” button.

This worked for me after a long time !! I hope it helps you.

This worked for me as a temporary fix:

import nbformat as nbf
from glob import glob

import uuid
def get_cell_id(id_length=8):
    return uuid.uuid4().hex[:id_length]

# your notebook name/keyword
nb_name = 'my_notebook'
notebooks = list(filter(lambda x: nb_name in x, glob("./*.ipynb", recursive=True)))

# iterate over notebooks
for ipath in sorted(notebooks):
    # load notebook
    ntbk = nbf.read(ipath, nbf.NO_CONVERT)
    
    cell_ids = []
    for cell in ntbk.cells:
        cell_ids.append(cell['id'])

    # reset cell ids if there are duplicates
    if not len(cell_ids) == len(set(cell_ids)): 
        for cell in ntbk.cells:
            cell['id'] = get_cell_id()

        nbf.write(ntbk, ipath)

I have been getting this as I do a lot of multi-cell ctrl-c/ctrl-v in my standard jupyter notebook lately (not jupyterlab). I am in jupyter_client 6.1.12 in Windows 10 installed using conda, working in firefox with Pytyon 3.7.6.

It seems to go away when I close/reopen the nb.

any solution yet?

I get a similar error saying cell ID was corrected to ‘domestic-communist’. From comments above it seems cell-id names are randomly generated. Maybe that randomization algorithm should be changed a bit. In this case I thought I was dealing with a virus…

Title: Notebook validation failed The save operation succeeded, but the notebook does not appear to be valid. The validation error was: Notebook validation failed: Non-unique cell id ‘moving-ultimate’ detected. Corrected to ‘domestic-communist’.: “<UNKNOWN>”

I am running: Classic Notebook (Not Jupyter Lab), v 6.2.0; Ubuntu; Chrome Browser Python 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 19:08:05)

I am having similar issues …

Workaround I’ve been using: cut in command mode (blue margin) but paste in edit mode (green margin).

No more errors.

Downside: when you paste in edit mode it all gets thrown into one cell, and it is put in code mode, so if you have a ton of formatted cells with lots of markdown, you will have to redo that). For my use case it is not that big of a deal so I’m pretty happy with this workaround.

@njohnsson You can see why we revoked the nbformat packages. It was horribly problematic and attempts to correct the lexicon where still showing problematic combinations. The new version (5.1.3) just uses hashes.

@EricThomson FYI the change needed is around nbformat and notebook server. The jupyter_client package is mostly unrelated.

@MSeal: OK, I will update package versions, but just FYI: I the latest message I got ended with “…Non-unique cell id ‘civil-spring’ detected. Corrected to ‘lesbian-voluntary’.”

Same thing happened to me and I found the solution. First select all the cells in the Jupyter Notebook, then press the “cut/scissors” button (don’t panic, at this point your Notebook will be empty), and finally press the “paste” button.

This worked for me after a long time !! I hope it helps you.

Thanks @saraafernandeez!!!

@saraafernandeez this is by far the easiest solution, especially if you have a lot of markdown cells. thank you!

@saraafernandeez Wonderful solution, thanks! Tested it.

FYI, here is the issue and pull request we made in jlab for supporting cell ids.

This message is related to some fairly recent changes to nbformat that introduce cell id metadata for each notebook cell. In this case, the validation logic is encountering a duplicate cell-id that was previously, and randomly, generated 'waiting-opening' and encountering that same cell-id later in the notebook. It’s strange that this occurs for the same cell-id value and is as if the corrected-to value is not getting persisted. I’m unable to reproduce this, but I suspect there are a few factors in play here.

I’m cc-ing @MSeal for comment as to what might be going on and how best to proceed (as I’d rather not recommend downgrading).