{"record":{"id":"08155a01f8d66fce","repo":"apple/pkl","slug":"string-08155a","errorCode":null,"errorMessage":"string","messagePattern":"string","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java","lineNumber":298,"sourceCode":"    throw new PklException(\"Could not read annotation. Invalid object type: \" + obj.getClass());\n  }\n\n  public static Checksums parseChecksums(Object obj) throws JsonParseException {\n    if (!(obj instanceof JsObject jsObj)) {\n      throw new FormatException(\"object\", obj.getClass());\n    }\n    var sha256 = jsObj.getString(\"sha256\");\n    return new Checksums(sha256);\n  }\n\n  public static List<String> parseAuthors(Object obj) throws JsonParseException {\n    if (!(obj instanceof JsArray arr)) {\n      throw new FormatException(\"array\", obj.getClass());\n    }\n    var ret = new ArrayList<String>(arr.size());\n    for (var elem : arr) {\n      if (!(elem instanceof String string)) {\n        throw new FormatException(\"string\", elem != null ? elem.getClass() : Void.class);\n      }\n      ret.add(string);\n    }\n    return ret;\n  }\n\n  private final String name;\n  private final PackageUri packageUri;\n  private final Version version;\n  private final URI packageZipUrl;\n  private final Checksums packageZipChecksums;\n  private final Map<String, RemoteDependency> dependencies;\n  private final @Nullable String sourceCodeUrlScheme;\n  private final @Nullable URI sourceCode;\n  private final @Nullable URI documentation;\n  private final @Nullable String license;\n  private final @Nullable String licenseText;\n  private final @Nullable List<String> authors;","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java#L280-L316","documentation":"Thrown by parseAuthors when an element inside the authors JSON array is not a String (or is null). Each author entry must be a plain string; the FormatException names the expected type \"string\" and the offending element's class (Void.class is used to represent null).","triggerScenarios":"Parsing metadata like {\"authors\":[\"Jane\", {\"name\":\"John\"}]} or {\"authors\":[null]} — any non-string array element.","commonSituations":"Metadata generated by third-party tooling that emits structured author objects (name/email objects) instead of plain strings, a convention used by other ecosystems but not Pkl.","solutions":["Convert each authors entry to a plain string (e.g. \"John <john@example.com>\")","Regenerate the metadata with the official Pkl serializer","Pre-validate that every element of the authors array is a string before parsing"],"exampleFix":"// before\n\"authors\": [\"Jane\", {\"name\": \"John\"}]\n// after\n\"authors\": [\"Jane\", \"John\"]","handlingStrategy":"validation","validationCode":"boolean allAuthorsAreStrings(Object o) {\n  return o instanceof List<?> l && l.stream().allMatch(e -> e instanceof String);\n}","typeGuard":"if (!(elem instanceof String s)) { throw new IllegalArgumentException(\"each author entry must be a string\"); }","tryCatchPattern":"try {\n  var authors = DependencyMetadata.parseAuthors(raw);\n} catch (FormatException e) {\n  log.error(\"Found a non-string author entry; flatten structured author objects to strings\", e);\n}","preventionTips":["Flatten structured author objects (name/email) into plain strings like \"Name <email>\"","Reject nulls in the authors array at generation time","Validate the authors array element types before parsing"],"tags":["pkl","json","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}