apple/pkl · error · MissingFieldException
value
Error message
value
What it means
MissingFieldException(jsObj, "value") is thrown by DependencyMetadata.parsePObject when a DataSize-typed annotation/metadata value lacks the required `value` field. A DataSize value must supply both a `unit` symbol and a numeric `value`; the missing field makes the size unrepresentable. It indicates an incomplete nested value object in the metadata.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/packages/DependencyMetadata.java:246
var className = classInfoObj.getString("class");
var moduleUri = classInfoObj.getString("moduleUri");
var props = jsObj.getObject("properties");
var classInfo = PClassInfo.get(moduleName, className, new URI(moduleUri));
var properties = new HashMap<String, Object>();
for (var kv : props.entrySet()) {
properties.put(kv.getKey(), parsePObject(kv.getValue()));
}
return new PObject(classInfo, properties);
}
case "Pattern" -> {
var value = jsObj.getString("value");
return Pattern.compile(value);
}
case "DataSize" -> {
var symbol = jsObj.getString("unit");
var value = jsObj.get("value");
if (value == null) {
throw new MissingFieldException(jsObj, "value");
}
var unit = DataSizeUnit.parse(symbol);
if (unit == null) {
throw new PklException("Invalid DataSize unit symbol: " + symbol);
}
if (!(value instanceof Double num)) {
throw new FormatException("double", value.getClass());
}
return new DataSize(num, unit);
}
case "Duration" -> {
var symbol = jsObj.getString("unit");
var value = jsObj.get("value");
if (value == null) {
throw new MissingFieldException(jsObj, "value");
}
var unit = DurationUnit.parse(symbol);
if (unit == null) {View on GitHub (pinned to f3efcbfc9b)
Solutions
- Add the numeric `value` field alongside `unit`, e.g. {"type": "DataSize", "unit": "mb", "value": 10.0}.
- Regenerate the metadata with `pkl project package`.
- Validate the metadata JSON against the expected nested-value shape before publishing.
- Check for truncated writes if the field was expected to be present.
Example fix
// before
{"type": "DataSize", "unit": "gb"}
// after
{"type": "DataSize", "unit": "gb", "value": 2.0} Defensive patterns
Strategy: validation
Validate before calling
var entry = root.get("...");
if (entry.get("type").asString().equals("DataSize")) {
if (!entry.has("value") || !entry.get("value").isNumber())
throw new IllegalStateException("DataSize entry requires numeric 'value' and 'unit'");
} Prevention
- Always emit both `unit` and numeric `value` for DataSize metadata.
- Schema-validate nested typed values before publishing.
- Prefer `pkl project package` for serialization to guarantee completeness.
- Check for truncation when files are written over slow links.
When it happens
Trigger: Parsing metadata whose entry of type "DataSize" contains {"unit": "mb"} with no "value" key.
Common situations: Hand-writing annotation values and omitting the numeric component; custom generators emitting only the unit; partially truncated metadata objects.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/0b01e0b87eef81ee.
Report an issue: GitHub.