{"record":{"id":"06e2c4803bee2e4f","repo":"stanfordnlp/CoreNLP","slug":"object-did-not-have-bbox-field","errorCode":null,"errorMessage":"object did not have bbox field","messagePattern":"object did not have bbox field","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/scenegraph/image/SceneGraphImageObject.java","lineNumber":59,"sourceCode":"  @SuppressWarnings(\"unchecked\")\n  public static SceneGraphImageObject fromJSONObject(SceneGraphImage img, JsonObject obj) {\n\n    List<String> names = SceneGraphImageUtils.getJsonStringList(obj, \"names\");\n    JsonArray labelArrays = obj.getJsonArray(\"labels\");\n    List<List<CoreLabel>> labelsList = null;\n    if (labelArrays != null) {\n      labelsList = Generics.newArrayList(labelArrays.size());\n      for (JsonArray arr : labelArrays.getValuesAs(JsonArray.class)) {\n        List<CoreLabel> tokens = Generics.newArrayList(arr.size());\n        for (JsonString str : arr.getValuesAs(JsonString.class)) {\n          tokens.add(SceneGraphImageUtils.labelFromString(str.getString()));\n        }\n        labelsList.add(tokens);\n      }\n    }\n    JsonObject boundingBoxObj = obj.getJsonObject(\"bbox\");\n    if (boundingBoxObj == null) {\n      throw new NullPointerException(\"object did not have bbox field\");\n    }\n\n    int h = boundingBoxObj.getInt(\"h\");\n    int w = boundingBoxObj.getInt(\"w\");\n    int x = boundingBoxObj.getInt(\"x\");\n    int y = boundingBoxObj.getInt(\"y\");\n\n    SceneGraphImageBoundingBox boundingBox = new SceneGraphImageBoundingBox(h, w, x, y);\n\n    return new SceneGraphImageObject(boundingBox, names, labelsList);\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public JsonObject toJSONObject(SceneGraphImage sceneGraphImage) {\n    JsonObjectBuilder obj = Json.createObjectBuilder();\n\n    JsonObjectBuilder bbox = Json.createObjectBuilder();\n    bbox.add(\"h\", this.boundingBox.h);","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/scenegraph/image/SceneGraphImageObject.java#L41-L77","documentation":"SceneGraphImageObject.fromJSONObject parses a JSON object describing one object in a Stanford Scene Graph Image. It requires the JSON to contain a \"bbox\" key holding the bounding box (h, w, x, y); when the key is absent the parser throws a NullPointerException so malformed data fails fast instead of producing an object with a null/invalid box.","triggerScenarios":"Calling SceneGraphImage.fromJSON (or related loaders) on a JSON file/string whose objects array contains an object entry missing the \"bbox\" field, e.g. hand-edited region descriptions, partially converted annotations, or a different annotation schema version.","commonSituations":"Working with legacy or third-party Visual Genome dumps that omit bbox for some objects; annotations exported by a tool that only writes region text; JSON files truncated or written by an older schema.","solutions":["Open the JSON file and add a \"bbox\" object with integer h, w, x, y to every object entry, or remove/fix the malformed object","Validate the JSON against the SceneGraphImage schema before loading (check each object has bbox)","If the data legitimately lacks boxes, skip such objects by pre-filtering the JSON array before calling fromJSON","Upstream-fix the annotation exporter so it always emits bbox"],"exampleFix":"// before (input JSON)\n{\"objects\":[{\"object_id\":1,\"names\":[\"dog\"]}]}\n// after\n{\"objects\":[{\"object_id\":1,\"names\":[\"dog\"],\"bbox\":{\"h\":120,\"w\":90,\"x\":10,\"y\":30}}]}","handlingStrategy":"validation","validationCode":"boolean hasBbox(JsonObject obj) {\n  JsonObject bbox = obj.getJsonObject(\"bbox\");\n  return bbox != null && bbox.containsKey(\"h\") && bbox.containsKey(\"w\")\n      && bbox.containsKey(\"x\") && bbox.containsKey(\"y\");\n}","typeGuard":"// Java: check Json nullability before use\nJsonObject bbox = obj.getJsonObject(\"bbox\");\nif (bbox == null) { throw new IllegalArgumentException(\"missing bbox in \" + obj); }","tryCatchPattern":null,"preventionTips":["Validate annotation JSON against the SceneGraphImage schema before loading","Prefilter objects arrays to entries containing bbox","Keep exporters and parser schema versions in sync","Fail fast on the first malformed object with a clear path/ID in the message"],"tags":["json","parsing","scenegraph","missing-field"],"backgroundTag":"schema-validation-failed","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}