phacility/phabricator · error · Exception

This Jupyter notebook does not specify a list of "cells".

Error message

This Jupyter notebook does not specify a list of "cells".

What it means

nbformat is 4, but the top-level 'cells' field is missing or is not an array (null, string, number). The engine requires 'cells' to be a PHP array because it iterates it to build the notebook table; any other shape is rejected before rendering.

Source

Thrown at src/applications/files/document/PhabricatorJupyterDocumentEngine.php:343

    $nbformat = idx($data, 'nbformat');
    if ($nbformat == null || !strlen($nbformat)) {
      throw new Exception(
        pht(
          'This document is missing an "nbformat" field. Jupyter notebooks '.
          'must have this field.'));
    }

    if ($nbformat !== 4) {
      throw new Exception(
        pht(
          'This Jupyter notebook uses an unsupported version of the file '.
          'format (found version %s, expected version 4).',
          $nbformat));
    }

    $cells = idx($data, 'cells');
    if (!is_array($cells)) {
      throw new Exception(
        pht(
          'This Jupyter notebook does not specify a list of "cells".'));
    }

    if (!$cells) {
      throw new Exception(
        pht(
          'This Jupyter notebook does not specify any notebook cells.'));
    }

    if (!$for_diff) {
      return $cells;
    }

    // If we're extracting cells to build a diff view, split code cells into
    // individual lines and individual outputs. We want users to be able to
    // add inline comments to each line and each output block.

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Ensure the top-level object contains "cells" as a JSON array of cell objects
  2. Re-export the notebook from Jupyter to regenerate a well-formed structure

Example fix

"cells": null

after:
"cells": [
  { "cell_type": "code", "metadata": {}, "source": [], "outputs": [] }
]
Defensive patterns

Strategy: validation

Validate before calling

$cells = idx($data, 'cells');
if (!is_array($cells)) {
  // 'cells' missing or not a list: reject before rendering
}

Try / catch

catch Exception and report the structural defect; ask for a re-export from Jupyter.

Prevention

When it happens

Trigger: A v4 notebook JSON object with 'cells' absent, null, or a scalar — e.g. scripts that reshape notebook JSON and drop or corrupt the cells key.

Common situations: Programmatically generated notebooks missing the cells array; JSON round-trips through tools that renamed or replaced the key.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/e945722906041f12. Report an issue: GitHub.