fix(config): keep git flake subdirectory refs as distinct inputs (#2704)#2877
Open
mikeland73 wants to merge 1 commit into
Open
fix(config): keep git flake subdirectory refs as distinct inputs (#2704)#2877mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
Two git flake references pointing at the same repository but different subdirectories (via the `dir` query parameter) are distinct inputs, yet devbox deduplicated them and only installed one. The root cause was `parseVersionedName`: it split package strings on `@` to separate name from version. Git flake URLs legitimately contain `@` in their `git@host` authority, so e.g. git+ssh://git@gitlab.com/org/repo.git?dir=betteralign&ref=...&rev=... git+ssh://git@gitlab.com/org/repo.git?dir=recovergoroutine&ref=...&rev=... both parsed to the name "git+ssh://git", with the rest dumped into the "version". Config.Packages() then deduplicates by name (lo.UniqBy), so one of the two inputs was silently dropped. Fix: treat flake references as unversioned in parseVersionedName, so the whole reference is used as the name. This keeps refs that differ only by query parameters distinct while leaving versioned devbox packages (and flake refs without an `@`) unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013x2JTaq6GPt4kX5bubQC2D
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where Devbox incorrectly deduplicated distinct git flake inputs that point to the same repo but different subdirectories (via ?dir=...), caused by @ in git@host being misinterpreted as the name@version delimiter during package parsing.
Changes:
- Update
parseVersionedNameto treat flake references as unversioned, preserving the full flake ref as the package name. - Extend
TestParseVersionedNamecoverage forgit+ssh://git@...flake URLs (with and without query params). - Add a regression test ensuring
Config.Packages()does not deduplicate distinct git flake refs that differ only bydir.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/devconfig/configfile/packages.go | Detect flake references early and avoid splitting on @, preventing incorrect deduplication. |
| internal/devconfig/configfile/packages_test.go | Adds test cases proving parseVersionedName preserves full git+ssh flake refs containing @. |
| internal/devconfig/config_test.go | Adds regression test asserting Config.Packages() preserves distinct git flake inputs differing by dir. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #2704.
Two git flake references that point at the same repository but different subdirectories (via the
dirquery parameter) are distinct inputs, but devbox deduplicated them and silently installed only one. For example:Only
dir=recovergoroutineended up indevbox.lockand got installed.Root cause
parseVersionedName(ininternal/devconfig/configfile/packages.go) split every package string on@to separate the name from the version. Git flake URLs legitimately contain an@in theirgit@hostauthority, so both of the refs above parsed to the namegit+ssh://git, with the rest of the URL (including the differentiatingdir) dumped into the "version".Config.Packages()then deduplicates packages by name (lo.UniqBy(p.Name)— used so that a version override wins over an included/plugin package). Because both refs shared the same parsed name, one of the two distinct inputs was dropped.Fix
Treat flake references as unversioned in
parseVersionedName, so the whole reference is used as the name. Flake refs aren't Devboxname@versionpackages, so this is also conceptually correct. This:dir) distinct, andpython@3.10,emacsPackages.@@latest, …) and flake refs without an@unchanged.The flake-detection reuses the existing
pkgtype.IsFlakehelper (no import cycle —pkgtypedoes not depend onconfigfile). The package'sVersionedName()output is unchanged for these refs, so no lockfile migration is needed.Tests
TestParseVersionedName: addedgit-ssh-flake-with-dirandgit-ssh-flake-without-querycases.TestPackagesDoesNotDedupDistinctGitFlakes: new regression test asserting thatConfig.Packages()preserves both git flakes that differ only bydir.(The two pre-existing
TestFindErrorpermission sub-tests fail only when the suite runs as root and are unrelated to this change.)cc @maxiem-ota-insight (issue author)
🤖 Generated with Claude Code
https://claude.ai/code/session_013x2JTaq6GPt4kX5bubQC2D
Generated by Claude Code