phacility/phabricator · error · Exception
This is not a valid JSON document and can not be rendered as
Error message
This is not a valid JSON document and can not be rendered as a Jupyter notebook: %s.
What it means
PhabricatorJupyterDocumentEngine::newCells() first parses the notebook with phutil_json_decode(); a PhutilJSONParserException means the file is not syntactically valid JSON at all, so it can never be a Jupyter notebook. The message includes the parser's detail (syntax error and position).
Source
Thrown at src/applications/files/document/PhabricatorJupyterDocumentEngine.php:311
'class' => 'jupyter-notebook',
),
$rows);
$container = phutil_tag(
'div',
array(
'class' => 'document-engine-jupyter',
),
$notebook_table);
return $container;
}
private function newCells($content, $for_diff) {
try {
$data = phutil_json_decode($content);
} catch (PhutilJSONParserException $ex) {
throw new Exception(
pht(
'This is not a valid JSON document and can not be rendered as '.
'a Jupyter notebook: %s.',
$ex->getMessage()));
}
if (!is_array($data)) {
throw new Exception(
pht(
'This document does not encode a valid JSON object and can not '.
'be rendered as a Jupyter notebook.'));
}
$nbformat = idx($data, 'nbformat');
if ($nbformat == null || !strlen($nbformat)) {
throw new Exception(
pht(
'This document is missing an "nbformat" field. Jupyter notebooks '.View on GitHub (pinned to 5720a38cfe)
Solutions
- Validate locally to find the exact syntax error: python -m json.tool file.ipynb
- Re-export the notebook from Jupyter (File > Save/Export) or re-download it and upload the fresh copy
- Fix the JSON defect directly (truncation, trailing commas, conflict markers) and re-upload
Defensive patterns
Strategy: validation
Validate before calling
$data = json_decode($raw, true);
if ($data === null && json_last_error() !== JSON_ERROR_NONE) {
// invalid JSON: reject before sending to the Jupyter engine
} Try / catch
catch Exception from the notebook renderer and show the embedded parser message — it pinpoints the JSON syntax error position.
Prevention
- Run python -m json.tool on exported notebooks before upload
- Lint .ipynb files as JSON in CI
When it happens
Trigger: Uploading a file treated as a notebook whose body is malformed JSON: truncated download, an HTML error page saved with a .ipynb extension, hand-edited JSON with a trailing comma, or merge-conflict markers left inside the file.
Common situations: Notebooks truncated during transfer or git conflicts resolved poorly; files saved from a browser preview instead of downloaded; notebooks corrupted by line-ending or encoding mangles.
Related errors
- This document does not encode a valid JSON object and can no
- This Jupyter notebook does not specify any notebook cells.
- Keyring configuration is not valid: value must be a list of
- Keyring configuration is not valid: each entry in the list m
- Keyring configuration has an invalid key specification (at i
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/4bdd740020fddb85.
Report an issue: GitHub.