Fix panic when devbox.lock contains null values #3154
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 367 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.353
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3154"
general
weight: 0.35
greptile-apps[bot]
Summary
Problem: devbox panics (nil pointer or "assignment to entry in nil map") when
devbox.lockhas a JSONnullwhere an object is expected. Fixes #3101.How it happens: devbox never writes these nulls itself. They come from a hand edit, a merge conflict fixed by hand, or a script that rewrites the lockfile (a Go program that marshals a nil map writes
null). Once the file has one, any command that loads the project hits it.Steps to reproduce: put
{"lockfile_version": "1", "packages": null}(or"packages": {"hello@latest": null}, or"systems": {"x86_64-linux": null}) indevbox.lock, then rundevbox add hello.Expected: the null is treated like a missing entry.
Actual: panic.
Cause:
lock.GetFiledecodes straight intoFile, sonullleavesPackagesnil (Resolvethen writes to a nil map) and leaves nilPackage/SystemInfoentries thatensurePackagesHaveOutputs,resolvedEntryandHasAllowInsecurePackagesdereference.Fix:
GetFilenow normalizes right after parsing: nilPackagesbecomes an empty map, and null package and system entries are dropped. A dropped package is resolved again on the next use, the same as one missing from the file. The issue title says "returning an error"; I chose to recover because the file has no real data for those entries, so there is nothing to refuse.Scope:
internal/boxcli/multi/sync.go(devbox updateacross several projects) reads lockfiles withoutGetFileand had the same nil dereference on a null package entry, so it now skips nulls. Otherlock.Fileusers go throughGetFile.How was it tested?
New tests:
TestGetFileNullValues(4 cases) andTestSyncLockfilesNullPackage. The sync test has one lockfile wherehellois null and another where it is valid, so the null entry reaches the update loop inSyncLockfiles; a third key is null everywhere to cover the latest-packages scan. Before the fix,TestGetFileNullValuesfails withPackages is nil, want an empty map, and the sync test panics with a nil pointer dereference inSyncLockfiles(sync.go:44 with the update-loop check removed, sync.go:90 with the scan check removed). After: pass.Commands:
GOTOOLCHAIN=local go vet,go test ./internal/lock/ ./internal/boxcli/multi/,gofmt -l,golangci-lint runon both packages (0 issues).Environment: fix branch @ 17f94bbd, go1.27.4, darwin/arm64
Community Contribution License
All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.
By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.