Repository navigation
Conversation
dbc sync --locked to install from the lockfile without updating it
This comment was marked as outdated.
This comment was marked as outdated.
…ating it dbc sync --locked plans every driver from its entry in a version 2 lock file, fetches no registry index and never writes the lock file. Before anything is downloaded it checks that the lock file matches the driver list (drivers, platforms as a set, version constraints with the pre-release setting, explicit sources) and that every entry has an artifact for this platform, a configured registry and a trusted signer. All problems are reported at once; mismatches point to dbc lock, trust problems to the configuration.
… --locked planLocked returned at the first lock file mismatch, so an untrusted signer or an unconfigured registry of another entry was only reported on the next run. Plan the drivers that the driver list has even when there are mismatches and report all problems together.
An undeclared host or a missing host artifact skipped the signer and registry checks of the entry. Check them for every driver of the driver list and report the undeclared host as one more problem.
The checks and the plan shared one loop, and every early continue could hide a later check. checkLockedReplay now runs each check whenever what it needs is there and only collects problems; planLocked builds the plan from what it found when neither it nor lockMismatches found a problem. An untrusted signer no longer hides an invalid artifact location. An invalid locked version is an error in both checks, since readLockFile already rejects it. fromLock is back to its original form.
…cked Since the signer of a lock entry is now checked against the policy of its bound registry, fromLock, relock and sync --locked all bind the registry, check the pinned signer and find the host artifact in the same order. replayLock does this once and records each problem; the normal plan stops at the first one and may complete a missing artifact from the index, while --locked collects every problem and completes nothing.
f1c0a11 to
863bcc6
Compare
A lock entry from a registry with its own key, or from an unsigned registry, installs without any index. Once the registry selects another signer, sync --locked fails before any download, also with --no-verify. The package is verified with the certificate that the signer check read.
zeroshade
left a comment
There was a problem hiding this comment.
LGTM. The preflight/replay split reads well, and the fromLock/relock refactor onto replayLock keeps the existing order of checks (bind, signer, artifact). A few small suggestions inline, none blocking.
| if i := slices.IndexFunc(d.Artifacts, func(a lockedArtifact) bool { return a.Target == host }); i >= 0 { | ||
| r.host = &d.Artifacts[i] | ||
| } | ||
| r.bound, r.trustErr = p.bind(name, d.Source.URL) |
There was a problem hiding this comment.
bind also fails when p.registries() itself errors (a configuration load failure), which isn't about this entry. Under --locked that one failure then gets repeated once per driver under "the configuration does not accept the lock file", followed by the signing-keys advice. Could replayLock return a p.registries() failure as its plain error and keep trustErr for an unconfigured registry or a signer mismatch? fromLock/relock wouldn't change, since they return it either way.
| // file. Mismatches between the lock file and the driver list are fixed by | ||
| // dbc lock; trust problems, such as a key that the lock file pins but the | ||
| // configuration does not trust, by checking that configuration first. | ||
| type lockedSyncError struct { |
There was a problem hiding this comment.
Since CI is the main use case: jsonErrorCode maps this to the generic fallback, so a --json consumer can't tell a stale lockfile from a network or registry failure without parsing the message. Maybe add a dedicated code (e.g. lock_mismatch / lock_untrusted), or expose mismatches/trust as structured fields in the error envelope?
| return nil, problems, err | ||
| } | ||
| if r.trustErr != nil { | ||
| problems.trust = append(problems.trust, r.trustErr.Error()) |
There was a problem hiding this comment.
Nit: a signer mismatch from trustedSigner already ends with signerChangeHint ("remove the lock file and run dbc lock…"), and the closing line of lockedSyncError then says to check the configuration because updating the lock file would change what it pins. Both make sense, but they show up one after the other. Maybe word the closing line as "if the key change is intended, …", or leave out the hint for items shown here?
| if _, ok := list.Drivers[d.Name]; !ok { | ||
| continue | ||
| } | ||
| v, err := semver.NewVersion(d.Version) |
There was a problem hiding this comment.
Nit: this branch (and the one in lockMismatches) can't trigger for a lockfile returned by readLockFile, because validate() already requires a canonical semver. Fine to keep for consistency with plan().
Add
dbc sync --lockedfor CI and other environments that need to install from a reviewed lockfile.dbc lockto create, migrate, or update the lockfile. If the configured registries or signing keys do not accept a locked entry, check the configuration first to preserve the existing pins.--lockedfollows the manifest-checking behavior of uv, Cargo, and Pixi. Their--frozenflags differ in how they handle manifest checks and network access.Note: #621 adds HTTP sources, which
--lockeddoes not handle yet. Whichever of the two PRs merges second should extend--lockedto them, reporting a removed HTTP declaration or a switch between HTTP and registry sources as a mismatch.