Repository navigation
fix: consistently match platforms by canonical target - #630
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
Looks correct overall: every consumer of PkgInfo.PlatformTuple parses it to a canonical target, and installed manifests/receipts stay keyed by the host tuple, so installing an aliased build doesn't affect reuse or cleanup. A few comments:
-
Ignored parse errors (
drivers.go:latestPackage,Versions,GetPackageusetarget, _ := resolution.TargetFromPlatformTuple(...)). This works because a zeroTargetnever matches, but that's implicit. It also changes behavior slightly: an unparseable requested platform passed throughinternal/apiResolve(e.g.linux-amd64or uppercase) used to match an identical raw index entry and now always reports "no package found". The CLI is unaffected since the host tuple is always valid. Either return the parse error or add a one-line comment that a zero target matches nothing by design. -
Ambiguity messages differ.
packageForVersionnames the caller's spelling (platformTuple), whilecmd/dbc/platforms.go:platformPackagenamestargetTuple(t), so the same condition reads... for linux_amd64_gnuin one place and... for linux_amd64in the other. -
Stricter v1 lock behavior. A v1 checksum recorded under
darwin_arm64is now verified against themacos_arm64archive. If a registry renamed the platform and also rebuilt the archive,dbc syncnow fails with a checksum mismatch instead of warning and ignoring the checksum. That's the right behavior for a lock, but it's worth calling out in the release notes. -
internal/api/api_test.gocoverage. Droppingurl: test-driver/1.0.0/linux.tar.gzremoves this test's check of relative packageurlresolution through the API. It's still covered indbc_api_test.go, so this is fine, but consider keeping a second package entry with the URL. -
Perf (non-blocking).
hasBuildFor/packageForVersionre-parse every tuple per lookup instead of a string compare; negligible at current index sizes.
Also worth mentioning in the description: packageForVersion now scans every record with the same version string, so a version split across records (host build in the second record) now resolves via GetPackage where it previously failed.
A version split across several records is not supported: the package lookup now uses only the record that was selected, and the CLI rejects a selected version listed in more than one record instead of combining their builds. Invalid platform tuples are reported as errors instead of matching nothing, and ambiguity messages spell the canonical target the same way in the CLI and the Go API.
|
Updated.
Split records are not supported, since one version record can already list every platform. |
zeroshade
left a comment
There was a problem hiding this comment.
Thanks, all earlier points are addressed. checkUniqueVersionRecord runs before any package lookup in fromLock, relock and selectProjectVersion, and a split pin is still reported through coversPlatforms/newestCoveringVersion rather than silently falling back to an older version. The error is not ErrPackageMiss, so registry fallback doesn't hide it.
One description note: "the CLI rejects duplicate records of the selected full version" holds for dbc sync, dbc lock and dbc add. dbc install (install.go), Client install (client_methods.go) and api.Resolve still go through GetLatestPackage/GetWithConstraint, which take the first record at the newest version with a host build, so a split version still installs there. #631/#634 close this; consider narrowing the wording or referencing them.
Minor inline notes below, none blocking.
| } | ||
| } | ||
|
|
||
| func TestDriverPackageLookupUsesOnlySelectedRecord(t *testing.T) { |
There was a problem hiding this comment.
This pins interim behaviour: GetLatestPackage succeeds from the second record while GetPackage(2.0.0, ...) reports "no package found". #634 turns the latter into an ambiguity error and removes GetLatestPackage, so this test will need rewriting there. Fine if intentional.
|
|
||
| // targetTuple spells t as a platform tuple. The libc of Linux is left out | ||
| // when it is the default. | ||
| func targetTuple(t resolution.Target) string { |
There was a problem hiding this comment.
Nit: targetTuple is now just t.PlatformTuple(). Callers could use the method directly and this wrapper could go.
| case !pinned: | ||
| reason = "the locked version no longer satisfies the version constraint" | ||
| case info.Platform != p.target: | ||
| case err != nil || !host.MatchesPlatformTuple(info.Platform): |
There was a problem hiding this comment.
Nit: a host tuple that fails to parse is reported as "not recorded for this platform". Unreachable in practice since plan() already rejects an invalid p.target, but the reason would be misleading if it ever happened.
Follow-ups to the non-blocking review notes on #630, #631, #634 and #635. `dbc sync` saves the lock file before installing. It already warned on install failure, but could exit without a warning after Ctrl-C or SIGINT. It now warns once on stderr if it saved the lock file and installation did not finish or could not be confirmed. On an install error, the warning asks you to fix it and rerun `dbc sync`. On interruption, it says installation "may be incomplete" and asks you to rerun, since the last install may have finished before sync received its result. Both warnings say the lock file "has been saved" to avoid implying that its contents changed. SIGINT stops the CLI program without canceling sync's worker context. On exit, sync prevents a preparation worker from starting a lock-file write and waits for any write already in progress before deciding whether to warn. Smaller follow-ups: - Call `Target.PlatformTuple()` directly (#630). - Explain why the ambiguity check uses registry pointers to distinguish configurations that share a URL (#631). - Clarify that `GetWithConstraint` ignores build metadata when selecting a record (#634).
Match registry packages by canonical target so a
macos_arm64host can find a build listed asdarwin_arm64.PkgInfo.PlatformTupleuse the original tuple from the index. Package lookups reject invalid platform tuples.Driver.Versionsreturns an empty list for invalid input.Closes #612.