apple/pkl · error · VmException
invalidProjectDepsJson
invalidProjectDepsJson
Error message
invalidProjectDepsJson
What it means
invalidProjectDepsJson is thrown by ProjectDependenciesManager.getProjectDeps when PklProject.deps.json was successfully read but failed JSON parsing (JsonParseException). The parse error message is included in the error so developers can locate the malformed spot. A SecurityManagerException at this point is treated as unreachable, so this error is purely about malformed JSON content.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/module/ProjectDependenciesManager.java:260
}
private ProjectDeps getProjectDeps() {
synchronized (lock) {
if (projectDeps == null) {
var depsUri = getProjectDepsFileUri();
var moduleKey = moduleResolver.resolve(depsUri);
try {
// treat PklProject.deps.json as a module read, rather than introduce a new API.
var depsJson = moduleKey.resolve(securityManager).loadSource();
projectDeps = ProjectDeps.parse(depsJson);
} catch (IOException e) {
throw new VmExceptionBuilder()
.evalError("cannotLoadProjectDepsJson", depsUri)
.withCause(e)
.withHint(e.getMessage() != null ? e.getMessage() : ("Encountered error: " + e))
.build();
} catch (JsonParseException e) {
throw new VmExceptionBuilder()
.evalError("invalidProjectDepsJson", depsUri, e.getMessage())
.build();
} catch (SecurityManagerException e) {
throw PklBugException.unreachableCode();
}
}
return projectDeps;
}
}
}
View on GitHub (pinned to f3efcbfc9b)
Solutions
- Fix the JSON syntax at the location given in the error message (trailing commas, unquoted keys, stray text).
- Regenerate the file with `pkl project resolve` instead of hand-editing it.
- Check for unresolved git merge-conflict markers (<<<<<<< ======= >>>>>>>) in PklProject.deps.json.
- Restore the file from source control if it was truncated or corrupted.
Example fix
// before (PklProject.deps.json, hand-edited)
{"schemaVersion": 1, "dependencies": {"foo": {"uri": "package://...",},},}
// after: regenerate
$ pkl project resolve Defensive patterns
Strategy: validation
Validate before calling
// Validate deps JSON before invoking pkl APIs
var mapper = new com.fasterxml.jackson.databind.ObjectMapper();
try { mapper.readTree(new File(projectDir, "PklProject.deps.json")); }
catch (IOException e) { throw new IllegalStateException("PklProject.deps.json is not valid JSON: " + e.getMessage()); } Prevention
- Treat PklProject.deps.json as generated: regenerate with `pkl project resolve` instead of editing.
- Run a JSON linter on the file after any manual edit.
- Ensure git merges are fully resolved (no conflict markers) before evaluating.
- Verify file integrity after downloads/interrupted writes.
When it happens
Trigger: Calling projectDeps, resolvedDep, or dep when the contents of PklProject.deps.json are not valid JSON — hand-edited lockfile, truncated download, merge-conflict markers left in the file, or BOM/encoding corruption.
Common situations: Developers hand-editing PklProject.deps.json and introducing a trailing comma or unquoted key; git merge conflicts resolved poorly; interrupted `pkl project resolve` leaving a partial file; copying deps.json through a tool that mangles encoding.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- cannotLoadProjectDepsJson
- Values of type `Duration` cannot be rendered as JSON. Value:
- Values of type `DataSize` cannot be rendered as JSON. Value:
- Values of type `Bytes` cannot be rendered as JSON. Value: %s
- Maps containing non-String keys cannot be rendered as JSON.
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/34c0b1ba1482c11d.
Report an issue: GitHub.