{"record":{"id":"83ba44459c00a68e","repo":"apple/pkl","slug":"array-83ba44","errorCode":null,"errorMessage":"array","messagePattern":"array","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java","lineNumber":169,"sourceCode":"          dependencies.get(\n              key,\n              (dep) -> {\n                if (!(dep instanceof JsObject obj)) {\n                  throw new FormatException(\"object\", dep.getClass());\n                }\n                var checksums = obj.get(\"checksums\", DependencyMetadata::parseChecksums);\n                var packageUri = obj.get(\"uri\", PackageUtils::parsePackageUriWithoutChecksums);\n                return new RemoteDependency(packageUri, checksums);\n              });\n      ret.put(key, remoteDependency);\n    }\n    return ret;\n  }\n\n  private static List<PObject> parseAnnotations(Object ann)\n      throws JsonParseException, URISyntaxException {\n    if (!(ann instanceof JsArray arr)) {\n      throw new FormatException(\"array\", ann.getClass());\n    }\n    var annotations = new ArrayList<PObject>(arr.size());\n    for (var annotation : arr) {\n      var obj = parsePObject(annotation);\n      if (!(obj instanceof PObject pObject)) {\n        throw new PklException(\"Could not read annotation. Invalid object: \" + obj);\n      }\n      annotations.add(pObject);\n    }\n    return annotations;\n  }\n\n  private static Object parsePObject(@Nullable Object obj)\n      throws JsonParseException, URISyntaxException {\n    if (obj == null) {\n      return PNull.getInstance();\n    } else if (obj instanceof String string) {\n      return string;","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java#L151-L187","documentation":"DependencyMetadata.parseAnnotations throws FormatException(\"array\", ann.getClass()) when the `annotations` field of dependency metadata is not a JSON array. The parser expects a list of annotation objects; a non-array value (object, string, null) fails. Like the other FormatExceptions here, it indicates a malformed metadata file.","triggerScenarios":"Parsing package metadata where `annotations` is missing its array shape — e.g. written as a single object instead of a one-element array, or as a string.","commonSituations":"Hand-authoring metadata and forgetting the array wrapper around a single annotation; custom metadata generators writing the wrong shape; schema drift between metadata producers and consumers.","solutions":["Write `annotations` as a JSON array, e.g. [ {...} ], even for a single annotation.","Regenerate the metadata with `pkl project package`.","Compare against a known-good published package's metadata shape and fix the producer.","Remove stray `annotations` fields if they are unnecessary for your package."],"exampleFix":"// before\n{\"annotations\": {\"author\": \"me\"}}\n// after\n{\"annotations\": [{\"name\": \"author\", \"value\": \"me\"}]}","handlingStrategy":"validation","validationCode":"if (root.has(\"annotations\") && !root.get(\"annotations\").isArray())\n  throw new IllegalStateException(\"metadata 'annotations' must be a JSON array\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always wrap annotations in an array, even for a single entry.","Generate metadata via `pkl project package` rather than hand-editing.","Validate the full metadata schema in CI.","Diff hand-edited metadata against a known-good published example."],"tags":["json","package-metadata","schema","pkl"],"backgroundTag":"schema-validation-failed","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}