{"record":{"id":"15028f9e6c2b0b3d","repo":"stanfordnlp/CoreNLP","slug":"image-does-not-have-height","errorCode":null,"errorMessage":"Image does not have height","messagePattern":"Image does not have height","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/scenegraph/image/SceneGraphImage.java","lineNumber":89,"sourceCode":"      for (JsonObject object: objects.getValuesAs(JsonObject.class)) {\n        img.objects.add(SceneGraphImageObject.fromJSONObject(img, object));\n      }\n\n      JsonArray attributes = obj.getJsonArray(\"attributes\");\n      for (JsonObject object: attributes.getValuesAs(JsonObject.class)) {\n        img.addAttribute(SceneGraphImageAttribute.fromJSONObject(img, object));\n      }\n\n      JsonArray relationships = obj.getJsonArray(\"relationships\");\n      for (JsonObject relation: relationships.getValuesAs(JsonObject.class)) {\n        img.addRelationship(SceneGraphImageRelationship.fromJSONObject(img, relation));\n      }\n\n      img.id = obj.getInt(\"id\");\n      Number height = obj.getInt(\"height\");\n      Number width = obj.getInt(\"width\");\n      if (height == null) {\n        throw new NullPointerException(\"Image does not have height\");\n      }\n      if (width == null) {\n        throw new NullPointerException(\"Image does not have width\");\n      }\n      img.height = height.intValue();\n      img.width = width.intValue();\n\n      img.url = obj.getString(\"url\");\n\n      return img;\n    } catch (RuntimeException e) {\n      throw new RuntimeException(\"Couldn't parse \\n\" + json, e);\n    }\n  }\n\n  @SuppressWarnings(\"unchecked\")\n  public String toJSON() {\n    JsonObjectBuilder json = Json.createObjectBuilder();","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/scenegraph/image/SceneGraphImage.java#L71-L107","documentation":"SceneGraphImage.readFromJSON reads image metadata from a JSON object. It calls obj.getInt(\"height\") and then checks the result; since JsonObject.getInt never returns null, the guard is effectively a schema assertion — but when the \"height\" key is absent/invalid the resulting failure surfaces as a NullPointerException with message \"Image does not have height\" at src/edu/stanford/nlp/scenegraph/image/SceneGraphImage.java:89. It means the input JSON is missing the required height field.","triggerScenarios":"Calling readFromJSON (directly or via SceneGraphImage.readFromFile/img) on a JSON object without an integer \"height\" key, or with \"height\": null.","commonSituations":"Scene-graph dataset files trimmed to only region/relationship data; custom JSON built by scripts that omit metadata fields; partial downloads of Visual Genome image metadata.","solutions":["Add the required \"height\" integer field to the JSON record.","Re-download the complete image metadata from the dataset source.","Pre-validate the JSON with containsKey/isNull before calling readFromJSON and skip or repair bad records.","Supply a default height from a separate metadata source if only dimensions are missing."],"exampleFix":"// before\nSceneGraphImage img = SceneGraphImage.readFromJSON(obj); // NPE, no height\n// after\nif (!obj.containsKey(\"height\") || obj.isNull(\"height\")) {\n  obj.put(\"height\", imageHeightLookup(obj.getInt(\"id\")));\n}\nSceneGraphImage img = SceneGraphImage.readFromJSON(obj);","handlingStrategy":"validation","validationCode":"if (!obj.containsKey(\"height\") || obj.isNull(\"height\") || !obj.containsKey(\"width\") || obj.isNull(\"width\")) {\n  throw new IllegalArgumentException(\"Image record missing dimensions: \" + obj.getInt(\"id\"));\n}","typeGuard":"boolean hasDimensions(JsonObject o) {\n  return o.containsKey(\"height\") && !o.isNull(\"height\") && o.containsKey(\"width\") && !o.isNull(\"width\");\n}","tryCatchPattern":"try {\n  return SceneGraphImage.readFromJSON(obj);\n} catch (RuntimeException e) {\n  log.warn(\"Skipping image without height: \" + obj.getInt(\"id\"));\n  return null;\n}","preventionTips":["Validate dataset JSON against the SceneGraphImage schema in preprocessing","Never strip metadata fields when slimming dataset files","Fail fast on the first malformed record in a dry-run pass"],"tags":["java","json","validation","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}