carlos / platform Public

cli: resolving -account must not require a registry that CI hasn't got

The release verbs run from a build machine as often as from a box, and a build
machine has no /data/registry.db at all. Opening one unconditionally to
resolve -account would have made `carlos ship` fail on every CI run — a
regression introduced by the flag itself.

"ops" is answered without opening anything, and a value that is already a sqid
is already the answer; only a NAME genuinely needs the registry, and only then
is its absence fatal — with an error that says to pass the sqid instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Paul Campbell 8e13480a0df0947f22058d25b37f4e4acaf657e6 parent a29ff1a
1 file changed, +9 −2
  • accounts.go +9 −2
diff --git a/accounts.go b/accounts.go
index d1c09e842..328741d64 100644
--- a/accounts.go
+++ b/accounts.go
@@ -280,12 +280,19 @@ func runAccountsMigrate(args []string) {
// guessy — picking the wrong account here would ship to the wrong tenant.
func resolveAccount(regPath, want string) string {
want = strings.TrimSpace(want)
- if want == "" {
+ if want == "" || want == "ops" {
return release.OpsAccount
}
+ // The release verbs run from CI as often as from a box, and a build
+ // machine has no registry at all. Not having one is only fatal if a NAME
+ // actually needs resolving: "ops" is answered above without opening
+ // anything, and a sqid is already the answer.
r, err := registry.Open(regPath)
if err != nil {
- log.Fatal(err)
+ if release.ValidAccount(want) {
+ return want
+ }
+ log.Fatalf("cannot resolve account %q: no registry at %s (%v) — pass the sqid instead of the name", want, regPath, err)
}
defer r.Close()
accts, err := r.Accounts()