carlos / platform Public

scanpass-skip-non-accounts

Squashed from scanpass-skip-non-accounts into main.
claude agent, operated by paul@keymail.dev 080ce5974139dee0ec460005521a379c2393745d parent e15fe61
2 files changed, +44 −0
  • internal/console/scanpass.go +7 −0
  • internal/console/scanpass_test.go +37 −0

CI passed — run details

diff --git a/internal/console/scanpass.go b/internal/console/scanpass.go
index 0638639d5..a606fba31 100644
--- a/internal/console/scanpass.go
+++ b/internal/console/scanpass.go
@@ -159,6 +159,13 @@ func (s *Server) scanPass(ctx context.Context) error {
for _, acctPrefix := range acctPrefixes {
acct := strings.TrimSuffix(strings.TrimPrefix(acctPrefix, "apps/"), "/")
+ // A legacy unqualified release prefix (apps/<app>/releases/, from
+ // before accounts) lists here as an "account" named for an app.
+ // It cannot hold a store, so skip it rather than fail the run on
+ // every tick — economicspass.go applies the same guard.
+ if !release.ValidAccount(acct) {
+ continue
+ }
appPrefixes, err := s.cfg.Releases.ListDirs(ctx, acctPrefix)
if err != nil {
return err
diff --git a/internal/console/scanpass_test.go b/internal/console/scanpass_test.go
index a6e651bf9..be2f5fbea 100644
--- a/internal/console/scanpass_test.go
+++ b/internal/console/scanpass_test.go
@@ -229,6 +229,43 @@ func TestScanPassContinuesPastOneAppsFailure(t *testing.T) {
}
}
+// A legacy unqualified release prefix (apps/<app>/releases/, from before
+// accounts) lists as an "account" whose name release.ValidAccount refuses.
+// It holds no store, so the pass skips it: it must neither fail the run on
+// the background-jobs page nor stop the real stores being swept.
+func TestScanPassSkipsLegacyUnqualifiedPrefix(t *testing.T) {
+ ctx := context.Background()
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.StoreScanner = objstore.NewMemScanner()
+
+ if release.ValidAccount("legacy-app") {
+ t.Fatal("test fixture assumption broken: \"legacy-app\" passes release.ValidAccount")
+ }
+ if _, err := fx.rel.Put(ctx, "apps/legacy-app/releases/dfe406a/manifest.json", []byte("{}"), ""); err != nil {
+ t.Fatal(err)
+ }
+ enableStore(t, fx, fixtureAcct, fixtureApp, true)
+ withLister(fx, &countingLister{keys: []string{"a.txt"}})
+
+ if err := fx.srv.jobs.Run(ctx, "StartScanPass", fx.srv.scanPass); err != nil {
+ t.Fatal(err)
+ }
+ st, ok := jobStatusOf(fx.srv, "StartScanPass")
+ if !ok {
+ t.Fatal("the run was not recorded")
+ }
+ if st.State != JobOK {
+ t.Fatalf("a legacy prefix failed the run: %v %q", st.State, st.Err)
+ }
+ side, _, err := objstore.GetSidecar(ctx, fx.rel, fixtureAcct, fixtureApp)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if side == nil || side.LastComplete == nil {
+ t.Fatal("the real store was not swept")
+ }
+}
+
// A sweep still in flight ignores the interval entirely. This is the only way
// a bucket larger than one budget ever finishes: if a part-done sweep waited
// out the re-sweep floor, a big store would advance one page a day.