Repository navigation
fix(lock,devpkg,nix): fix package parsing, flake input names, and lockfile resolve bugs - #3010
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
CanonicalName, version and isVersioned used the first @, which is inconsistent with searcher.ParseVersionedPackage and breaks names like nodePackages.@vue/cli@5.0. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A pinned rev can't change, so refreshing only downloads the source and rewrites the lock entry with lastModified and narHash params. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
UpdateStdenv saved the lockfile without the stdenv entry before re-resolving it, so a failed resolve left devbox.lock without one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A truncated cache file made PrintDevEnv fail with an unmarshal error until the cache was manually deleted. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Network and server errors from the search service were all reported as "package not found". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Collaborator
Author
|
@claude please review |
|
Claude finished @mikeland73's task in 24s —— View job Review of #3010I read the non-test diff and checked the changes against their callers. I didn't build the code or run the tests. I found no blocking issues. Checked and fine
Minor notes (non-blocking)
The changes are targeted and the tests cover the parts that can be tested without nix or network. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a batch of bugs in package resolution, the lockfile, and nix helpers (
internal/devpkg,internal/lock,internal/nix, andDevbox.Outdated).devbox list --outdatedpanic (internal/devbox/packages.go:65):lockfile.Packages[pkg.Raw]was dereferenced without a nil check, so a missingdevbox.lockor a package that wasn't locked yet caused a panic. Unlocked packages are now skipped, since they get locked to the latest version on the next install anyway.internal/devpkg/package.go:162):strings.Split("", ",")returns[""], so a flake without^outputsgot an empty output name. With--outputs dev,outthe outputs became["", "dev", "out"], which produced invalid nix (input.curl.) and duplicate installables. Empty entries are now filtered out.@splitting (internal/devpkg/package.goCanonicalName/version/isVersioned): these split on the first@, butsearcher.ParseVersionedPackagesplits on the last one.nodePackages.@vue/cli@5.0therefore got the canonical namenodePackages.. All three now usesearcher.ParseVersionedPackage.internal/devpkg/package.goFlakeInputName): non-nixpkgs GitHub inputs were named onlygh-<owner>-<repo>-<rev|ref>.github:o/r/<rev>?dir=aand?dir=b(or a differenthost) ended up with the same name. Whendirorhostis set, a short hash of the ref is now appended. Names for the common case don't change.devbox updatere-fetches pinned GitHub flakes (internal/lock/resolve.golockFlake): the!refreshcondition turned off the shortcut for GitHub refs that are already pinned to a rev. Update then downloaded the source and rewrote the lock entry withlastModified/narHashparams. A pinned rev can't change, so the shortcut now also applies on refresh.last_modified(internal/lock/resolve.go:47): when a flake had nolastModified,time.Unix(0, 0)wrote1970-01-01T00:00:00Zto the lockfile. The field is now left empty.internal/nix/storepath.go):glibc-2.39-52-binwas parsed as version2.39with output52-bin.foo-0-unstable-2024-01-01got outputunstable-2024-01-01. Now only the last dash-separated component counts as the output, and only if it starts with a letter.UpdateStdenvcould drop the stdenv (internal/lock/lockfile.go:144):Remove()saved the lockfile without the stdenv entry before re-resolving it, so a failed resolve left the lockfile without a stdenv. The old entry is now removed only in memory and put back if resolving fails.internal/nix/nix.goPrintDevEnv): an unmarshal error on the cache file was returned to the caller, so a truncated cache brokePrintDevEnvuntil someone deleted the file by hand. The bad cache is now ignored and the env is recomputed, which rewrites the cache.internal/lock/resolve.go:70): network errors and 5xx responses from/v1/resolvewere all turned intoErrPackageNotFound. Onlysearcher.ErrNotFoundmaps to it now. This matches the existing v2 path.%!(EXTRA <nil>)in error message (internal/nix/store.go:164): removed an extra argument that had no matching verb in the format string.trusted-users = *not handled (internal/nix/config.goIsUserTrusted): a*entry now counts as trusting every user.How was it tested?
internal/devpkg:TestFlakeOutputNames,TestVersioned,TestFlakeInputNameUnique, plus newTestCanonicalNamecases.internal/lock:TestFetchResolvedPackagePinnedGitHubFlake(covers the pinned-rev refresh and the emptylast_modified) andTestFetchResolvedPackageSearchErrors(an httptest search server returning 404 and 500).internal/nix: newTestStorePathPartscases andTestConfigIsUserTrusted/Wildcard.Outdatednil check,UpdateStdenv, the print-dev-env cache, or thestore.goformat string. Testing these needs a real nix binary, network access, or a full Devbox project.go build ./...,go vet,go testfor./internal/devpkg/... ./internal/lock/... ./internal/nix/... ./internal/devbox/... ./internal/shellgen/...,go tool golangci-lint run(0 issues), andgofumpt.🤖 Generated with Claude Code