From b9cc7db240315375d21c0375bd0e5c4dfd704fe5 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sat, 18 Oct 2025 10:03:53 +0200 Subject: [PATCH] Fix "expected null or a string, got: int" on Jupyter Notebook Summary: The value needs to be an integer per specification and per the next check in the code. Previous rPb08c7c761c1078658da02ba68fcb4b0f67912438 was not fully correct. ``` EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_string() expected null or a string, got: int. at [/src/utils/utils.php:2121] #0 <#2> phutil_nonempty_string(integer) called at [/src/applications/files/document/PhabricatorJupyterDocumentEngine.php:326] ``` Fixes T16312 Test Plan: * Go to http://phorge.localhost/file/upload/ * Upload a valid JSON text file: `{"nbformat": 0, "nbformat_minor": 5, "metadata": {}, "cells": []}` * On resulting http://phorge.localhost/F1, select "View Options > View as Jupyter Notebook" Reviewers: O1 Blessed Committers, mainframe98 Reviewed By: O1 Blessed Committers, mainframe98 Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16312 Differential Revision: https://we.phorge.it/D26435 --- .../files/document/PhabricatorJupyterDocumentEngine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php index 7ec78843e7..7f1366df71 100644 --- a/src/applications/files/document/PhabricatorJupyterDocumentEngine.php +++ b/src/applications/files/document/PhabricatorJupyterDocumentEngine.php @@ -323,11 +323,11 @@ final class PhabricatorJupyterDocumentEngine } $nbformat = idx($data, 'nbformat'); - if (!phutil_nonempty_string($nbformat)) { + if (!is_int($nbformat)) { throw new Exception( pht( - 'This document is missing an "nbformat" field. Jupyter notebooks '. - 'must have this field.')); + 'This document lacks a valid "nbformat" field. Jupyter notebooks '. + 'must have this field and it must have an integer value.')); } if ($nbformat !== 4) { -- 2.51.2