carlos / platform Public

console: purge skips unread claims of unknown account; refusal copy

An unread claim blocks a purge's claim release only when the listing knew
it as this account's; one with an unknown account is skipped with an
hourly log line naming its key, so one bad object cannot stall every purge.
The account-deletion refusal draft names the domains and says the account
can't be deleted while it holds them, naming no action users lack.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev a3d43adedd102b075c2b4b12a61d8eb779175245 parent fc181e1
3 files changed, +47 −8
  • internal/console/domainbuy_copy.go +2 −2
  • internal/console/lifetimes_purge.go +14 −6
  • internal/console/lifetimes_purge_test.go +31 −0

CI failed — run details

diff --git a/internal/console/domainbuy_copy.go b/internal/console/domainbuy_copy.go
index 93828a285..fd295dcda 100644
--- a/internal/console/domainbuy_copy.go
+++ b/internal/console/domainbuy_copy.go
@@ -123,8 +123,8 @@ func (s *Server) domainBuyRegistrarRefusal(ctx context.Context, acct *Account, n
// (2026-11-19), awaiting the copy pass. Named takes the domains, comma
// separated; Count is the store's own re-check, which knows only how many.
var accountDomainsCopy = struct{ Named, Count, Unreadable string }{
- Named: "This account holds domains it registered or is buying: %s. Transfer each one out or release it, then delete the account.",
- Count: "This account holds domains it registered or is buying. Transfer each one out or release it, then delete the account.",
+ Named: "This account can't be deleted while it holds domains it registered or is buying: %s.",
+ Count: "This account can't be deleted while it holds domains it registered or is buying.",
Unreadable: "Could not check whether this account holds domains. Nothing was deleted.",
}
diff --git a/internal/console/lifetimes_purge.go b/internal/console/lifetimes_purge.go
index 990e5497b..5ce04d2b2 100644
--- a/internal/console/lifetimes_purge.go
+++ b/internal/console/lifetimes_purge.go
@@ -322,11 +322,15 @@ func (s *Server) releaseAppDomainClaimsGuarded(ctx context.Context, sqid, app st
}
// appDomainClaims is sqid/app's custom-domain claims, sorted by host. A
-// claim the listing could not read that may be this account's custom
-// domain (its account this one or unknown) is read again on its own: gone
-// is skipped, still unreadable fails the purge (it fails toward keeping),
-// and a readable one is judged like the rest. Nothing under the host-claim
-// gate (releaseAppDomainClaims).
+// claim the listing could not read on a custom-domain host is judged by the
+// account the listing last knew for it. This account's is read again on its
+// own: gone is skipped, still unreadable fails this purge (it fails toward
+// keeping), and a readable one is judged like the rest. An unknown account
+// (a body never read, such as an unparseable one) does not stop the purge:
+// it is skipped with one log line an hour naming its key, so one bad object
+// cannot stall every purge on the deployment; a claim left behind that way
+// is what every purge left before. Another account's is never this app's.
+// Nothing under the host-claim gate (releaseAppDomainClaims).
func (s *Server) appDomainClaims(ctx context.Context, sqid, app string) ([]domains.Claim, error) {
if s.cfg.HostClaim || s.cfg.Releases == nil {
return nil, nil
@@ -346,7 +350,11 @@ func (s *Server) appDomainClaims(ctx context.Context, sqid, app string) ([]domai
}
}
for _, u := range unread {
- if (u.Account != "" && u.Account != sqid) || !custom(u.Host) {
+ if u.Account != sqid || !custom(u.Host) {
+ if u.Account == "" && custom(u.Host) {
+ key := domains.ClaimKey(u.Host)
+ s.lifetimeLogHourly("purge-unread-claim "+key, "console: purge %s/%s: skipping the unread claim %s (its account is unknown)", sqid, app, key)
+ }
continue
}
c, err := domains.GetClaim(ctx, s.cfg.Releases, u.Host)
diff --git a/internal/console/lifetimes_purge_test.go b/internal/console/lifetimes_purge_test.go
index 4d1f812ce..14b53649e 100644
--- a/internal/console/lifetimes_purge_test.go
+++ b/internal/console/lifetimes_purge_test.go
@@ -1,13 +1,16 @@
package console
import (
+ "bytes"
"context"
"encoding/json"
"errors"
+ "log"
"net/http"
"net/url"
"os"
"slices"
+ "strings"
"sync/atomic"
"testing"
"time"
@@ -677,3 +680,31 @@ func TestLegacyPurgeBranchesReleaseClaims(t *testing.T) {
}
})
}
+
+// An unread claim whose account nobody knows (an unparseable body, never read
+// before) does not stop the purge: it is skipped with one log line naming its
+// key, and the app's readable claims are released.
+func TestPurgeSkipsUnreadClaimOfUnknownAccount(t *testing.T) {
+ l := purgeClaimsWorld(t)
+ odd := domains.ClaimKey("odd.example")
+ if _, err := l.fx.rel.Put(context.Background(), odd, []byte("{not json"), ""); err != nil {
+ t.Fatal(err)
+ }
+ var logged bytes.Buffer
+ log.SetOutput(&logged)
+ t.Cleanup(func() { log.SetOutput(os.Stderr) })
+ if err := purgeCore(t, l.fx.srv, onCtx(t, l.fx.srv), time.Time{}); err != nil {
+ t.Fatalf("purge = %v, want it to finish past the unread claim", err)
+ }
+ log.SetOutput(os.Stderr)
+ wantShopClaimsReleased(t, l.fx.rel)
+ if tomb, err := release.ReadAppTombstone(context.Background(), l.fx.rel, "bab", ltApp); err != nil || tomb != nil {
+ t.Fatalf("marker = %+v %v, want gone", tomb, err)
+ }
+ if !strings.Contains(logged.String(), "skipping the unread claim "+odd) {
+ t.Fatalf("the log does not name the unread key %s:\n%s", odd, logged.String())
+ }
+ if raw, _, err := l.fx.rel.Get(context.Background(), odd); err != nil || string(raw) != "{not json" {
+ t.Fatalf("the unread claim = %q %v, want it left as it was", raw, err)
+ }
+}