{"record":{"id":"b02ee3540eafb7ff","repo":"phacility/phabricator","slug":"this-document-does-not-encode-a-valid-json-object","errorCode":null,"errorMessage":"This document does not encode a valid JSON object and can not be rendered as a Jupyter notebook.","messagePattern":"This document does not encode a valid JSON object 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":319,"sourceCode":"      ),\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 '.\n          'must have this field.'));\n    }\n\n    if ($nbformat !== 4) {\n      throw new Exception(\n        pht(\n          'This Jupyter notebook uses an unsupported version of the file '.\n          'format (found version %s, expected version 4).',","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/document/PhabricatorJupyterDocumentEngine.php#L301-L337","documentation":"The file parsed as valid JSON, but phutil_json_decode() returned a non-array (a scalar such as a number, string, or boolean). A notebook must be a JSON object at its root, so the engine refuses to render it. This is a type check one step beyond syntax: valid JSON, wrong shape.","triggerScenarios":"A .ipynb file whose JSON root is a scalar — e.g. content '5', '\"hello\"', or 'true' — which decodes to int/string/bool rather than an array.","commonSituations":"Plain text or single-value JSON files renamed to .ipynb; API responses pasted into a notebook file; scaffolding scripts writing a scalar placeholder.","solutions":["Open the file and confirm it is a notebook object starting with '{' and containing 'nbformat' and 'cells'","Replace the file with a real notebook exported from Jupyter"],"exampleFix":"file.ipynb (before):\n\"no notebook here\"\n\nfile.ipynb (after):\n{\n  \"nbformat\": 4,\n  \"nbformat_minor\": 5,\n  \"metadata\": {},\n  \"cells\": []\n}","handlingStrategy":"validation","validationCode":"$data = json_decode($raw, true);\nif (!is_array($data)) {\n  // root is not an object/list: not a notebook\n}","typeGuard":null,"tryCatchPattern":"catch Exception and surface 'not a valid notebook object' to the user; offer the raw file view.","preventionTips":["Only upload notebook files produced by Jupyter exporters","Programmatically check the root is an object before treating a file as a notebook"],"tags":["jupyter","json","type-validation","shape-mismatch"],"backgroundTag":"invalid-jupyter-notebook","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}