{"record":{"id":"4bdd740020fddb85","repo":"phacility/phabricator","slug":"this-is-not-a-valid-json-document-and-can-not-be-r","errorCode":null,"errorMessage":"This is not a valid JSON document and can not be rendered as a Jupyter notebook: %s.","messagePattern":"This is not a valid JSON document and can not be rendered as a Jupyter notebook: (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/document/PhabricatorJupyterDocumentEngine.php","lineNumber":311,"sourceCode":"        'class' => 'jupyter-notebook',\n      ),\n      $rows);\n\n    $container = phutil_tag(\n      'div',\n      array(\n        'class' => 'document-engine-jupyter',\n      ),\n      $notebook_table);\n\n    return $container;\n  }\n\n  private function newCells($content, $for_diff) {\n    try {\n      $data = phutil_json_decode($content);\n    } catch (PhutilJSONParserException $ex) {\n      throw new Exception(\n        pht(\n          'This is not a valid JSON document and can not be rendered as '.\n          'a Jupyter notebook: %s.',\n          $ex->getMessage()));\n    }\n\n    if (!is_array($data)) {\n      throw new Exception(\n        pht(\n          'This document does not encode a valid JSON object and can not '.\n          'be rendered as a Jupyter notebook.'));\n    }\n\n    $nbformat = idx($data, 'nbformat');\n    if ($nbformat == null || !strlen($nbformat)) {\n      throw new Exception(\n        pht(\n          'This document is missing an \"nbformat\" field. Jupyter notebooks '.","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/document/PhabricatorJupyterDocumentEngine.php#L293-L329","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$data = json_decode($raw, true);\nif ($data === null && json_last_error() !== JSON_ERROR_NONE) {\n  // invalid JSON: reject before sending to the Jupyter engine\n}","typeGuard":null,"tryCatchPattern":"catch Exception from the notebook renderer and show the embedded parser message — it pinpoints the JSON syntax error position.","preventionTips":["Run python -m json.tool on exported notebooks before upload","Lint .ipynb files as JSON in CI"],"tags":["json","jupyter","parsing","validation"],"backgroundTag":"invalid-jupyter-notebook","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}