{"record":{"id":"0e6bfd7611907589","repo":"apple/pkl","slug":"invalid-datasize-unit-symbol","errorCode":null,"errorMessage":"Invalid DataSize unit symbol: ","messagePattern":"Invalid DataSize unit symbol: ","errorType":"exception","errorClass":"PklException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java","lineNumber":250,"sourceCode":"          var properties = new HashMap<String, Object>();\n          for (var kv : props.entrySet()) {\n            properties.put(kv.getKey(), parsePObject(kv.getValue()));\n          }\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());","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java#L232-L268","documentation":"PklException(\"Invalid DataSize unit symbol: \" + symbol) is thrown by DependencyMetadata.parsePObject when the `unit` field of a DataSize value is not a recognized DataSizeUnit symbol (e.g. \"b\", \"kb\", \"mb\", \"gb\", \"tb\"...). An unrecognized symbol means the metadata cannot construct a DataSize. It indicates a typo or wrong-casing in the unit symbol.","triggerScenarios":"Parsing metadata with a DataSize entry whose `unit` is an unknown string such as \"MB\", \"megabytes\", \"kib\", or an empty string.","commonSituations":"Hand-written annotations using human unit names; case-sensitivity mistakes (\"MB\" vs \"mb\"); confusion between binary unit families supported by Pkl's DataSizeUnit.","solutions":["Use a valid Pkl DataSize unit symbol with correct casing, e.g. \"kb\", \"mb\", \"gb\" (or binary variants like \"kib\", \"mib\").","Regenerate the metadata with `pkl project package` so units are serialized canonically.","Check DataSizeUnit.parse for the exact accepted symbol list and match it.","Fall back to the base unit (e.g. convert to \"b\" bytes) if unsure."],"exampleFix":"// before\n{\"type\": \"DataSize\", \"unit\": \"MB\", \"value\": 10.0}\n// after\n{\"type\": \"DataSize\", \"unit\": \"mb\", \"value\": 10.0}","handlingStrategy":"validation","validationCode":"var validUnits = java.util.Set.of(\"b\",\"kb\",\"mb\",\"gb\",\"tb\",\"pb\",\"kib\",\"mib\",\"gib\",\"tib\",\"pib\");\nvar unit = entry.get(\"unit\").asString();\nif (!validUnits.contains(unit)) throw new IllegalStateException(\"Unknown DataSize unit symbol: \" + unit);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use canonical lowercase Pkl unit symbols (b, kb, mb, ... and kib, mib, ...); check DataSizeUnit.parse for the exact list.","Never write human forms like \"MB\" or \"megabytes\" into metadata.","Let the packaging tool serialize units instead of typing them manually.","Add unit-symbol validation to your metadata linter."],"tags":["json","package-metadata","unit","datasize","pkl"],"backgroundTag":"invalid-enum-value","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"}