{"record":{"id":"f07af8a100cd850b","repo":"phacility/phabricator","slug":"this-jupyter-notebook-uses-an-unsupported-version","errorCode":null,"errorMessage":"This Jupyter notebook uses an unsupported version of the file format (found version %s, expected version 4).","messagePattern":"This Jupyter notebook uses an unsupported version of the file format \\(found version (.+?), expected version 4\\)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/document/PhabricatorJupyterDocumentEngine.php","lineNumber":334,"sourceCode":"    }\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).',\n          $nbformat));\n    }\n\n    $cells = idx($data, 'cells');\n    if (!is_array($cells)) {\n      throw new Exception(\n        pht(\n          'This Jupyter notebook does not specify a list of \"cells\".'));\n    }\n\n    if (!$cells) {\n      throw new Exception(\n        pht(\n          'This Jupyter notebook does not specify any notebook cells.'));\n    }","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/document/PhabricatorJupyterDocumentEngine.php#L316-L352","documentation":"The notebook declares an 'nbformat' value other than 4. The engine supports only nbformat 4 and enforces it with a strict comparison ($nbformat !== 4), so any other major version — and even the string \"4\" instead of the number 4 — is rejected.","triggerScenarios":"nbformat 3 (legacy IPython-era notebooks) or any newer/experimental format; also 'nbformat': \"4\" written as a JSON string, which fails the strict !== comparison against integer 4.","commonSituations":"Old v3 notebooks from the IPython era kept in archives; tools that serialize nbformat as a string; internal formats bumping the major version.","solutions":["Upgrade the notebook to format 4: jupyter nbconvert --to notebook --nbformat 4 --output upgraded.ipynb old.ipynb (or open and re-save in a current Jupyter)","If the value is the string \"4\", rewrite it as the JSON number 4","Keep the legacy copy elsewhere and upload the converted v4 file"],"exampleFix":"\"nbformat\": 3,\n\"nbformat_minor\": 0\n\nafter:\n\"nbformat\": 4,\n\"nbformat_minor\": 5","handlingStrategy":"validation","validationCode":"$nbformat = idx($data, 'nbformat');\nif ($nbformat !== 4) {\n  // strict check: string \"4\" also fails; convert or reject\n}","typeGuard":null,"tryCatchPattern":"catch Exception and direct the user to convert the notebook to format 4 (jupyter nbconvert --nbformat 4).","preventionTips":["Upgrade legacy v3 notebooks to v4 as part of ingestion","Ensure tools write nbformat as a JSON number, not a string"],"tags":["jupyter","version-mismatch","strict-comparison"],"backgroundTag":"invalid-jupyter-notebook","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}