{"record":{"id":"6f512738e76c1772","repo":"apple/pkl","slug":"double","errorCode":null,"errorMessage":"double","messagePattern":"double","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java","lineNumber":253,"sourceCode":"          }\n          return new PObject(classInfo, properties);\n        }\n        case \"Pattern\" -> {\n          var value = jsObj.getString(\"value\");\n          return Pattern.compile(value);\n        }\n        case \"DataSize\" -> {\n          var symbol = jsObj.getString(\"unit\");\n          var value = jsObj.get(\"value\");\n          if (value == null) {\n            throw new MissingFieldException(jsObj, \"value\");\n          }\n          var unit = DataSizeUnit.parse(symbol);\n          if (unit == null) {\n            throw new PklException(\"Invalid DataSize unit symbol: \" + symbol);\n          }\n          if (!(value instanceof Double num)) {\n            throw new FormatException(\"double\", value.getClass());\n          }\n          return new DataSize(num, unit);\n        }\n        case \"Duration\" -> {\n          var symbol = jsObj.getString(\"unit\");\n          var value = jsObj.get(\"value\");\n          if (value == null) {\n            throw new MissingFieldException(jsObj, \"value\");\n          }\n          var unit = DurationUnit.parse(symbol);\n          if (unit == null) {\n            throw new PklException(\"Invalid Duration unit symbol: \" + symbol);\n          }\n          if (!(value instanceof Double num)) {\n            throw new FormatException(\"double\", value.getClass());\n          }\n          return new Duration(num, unit);\n        }","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java#L235-L271","documentation":"FormatException(\"double\", value.getClass()) is thrown by DependencyMetadata.parsePObject when the `value` field of a DataSize entry is present but not a JSON number (Double). DataSize values must be numeric; strings like \"10mb\" or booleans are rejected. It indicates a wrong-typed value in the metadata.","triggerScenarios":"Parsing metadata with a DataSize entry such as {\"type\": \"DataSize\", \"unit\": \"mb\", \"value\": \"10\"} — value is a string rather than a JSON number.","commonSituations":"Hand-writing annotations and quoting the number; custom generators serializing sizes as formatted strings like \"10.5mb\"; YAML-to-JSON conversions turning numbers into strings.","solutions":["Write `value` as an unquoted JSON number: {\"value\": 10.0}.","Move any unit text out of the string and into the `unit` field.","Regenerate metadata with `pkl project package` to ensure correct typing.","Fix converters/tools that stringify numeric fields during serialization."],"exampleFix":"// before\n{\"type\": \"DataSize\", \"unit\": \"mb\", \"value\": \"10\"}\n// after\n{\"type\": \"DataSize\", \"unit\": \"mb\", \"value\": 10.0}","handlingStrategy":"validation","validationCode":"if (entry.get(\"type\").asString().equals(\"DataSize\")) {\n  var v = entry.get(\"value\");\n  if (v == null || !v.isNumber()) throw new IllegalStateException(\"DataSize 'value' must be a JSON number, got: \" + v);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never quote numeric values in metadata JSON.","Split combined strings like \"10.5mb\" into numeric value plus unit field.","Configure converters/serializers to keep numbers unquoted.","Validate value types with a JSON schema in CI."],"tags":["json","package-metadata","type-mismatch","datasize","pkl"],"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"}