console: backups fix round 1, unread record, other-region line (#898)
When the instance's record can't be read, nothing is known about either row (born HA included), so both now show "Can't read now" with no reason line, tiles or command, instead of claiming the files aren't copied. TestInstancePageBackupsRecordUnread fails the record's read through the store and is distinct from the failing replica listing case. backups.why.otherregion is Paul's re-approved text (copy review 2jhfdd2h7oiirvygyoivpyq2ja): "Use the command line below to get one." replaces the promise of a Download button the page doesn't have yet. The copy record notes the re-approval.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+56
−5
docs/superpowers/plans/member-backups-slice1-copy.json+1 −1internal/console/instancecopy.go+1 −1internal/console/instancepage.go+4 −1internal/console/instancepage_test.go+50 −2
CI failed — run details
diff --git a/docs/superpowers/plans/member-backups-slice1-copy.json b/docs/superpowers/plans/member-backups-slice1-copy.json| index 374cca758..4b8448f48 100644 |
| --- a/docs/superpowers/plans/member-backups-slice1-copy.json |
| +++ b/docs/superpowers/plans/member-backups-slice1-copy.json |
| @@ -30,7 +30,7 @@ |
| {"id": "backups.why.demo", "file": "internal/console/instancecopy.go", "text": "Demo data isn't kept."}, |
| {"id": "backups.why.pooled", "file": "internal/console/instancecopy.go", "text": "Copies of pooled instances aren't shown here yet."}, |
| {"id": "backups.why.fleet", "file": "internal/console/instancecopy.go", "text": "Copies on your own servers aren't shown here yet."}, |
| - {"id": "backups.why.otherregion", "file": "internal/console/instancecopy.go", "text": "Copies in {region} aren't shown here yet. You can still download one."}, |
| + {"id": "backups.why.otherregion", "file": "internal/console/instancecopy.go", "text": "Copies in {region} aren't shown here yet. Use the command line below to get one.", "note": "Re-approved by Paul on 2026-11-11 in copy review 2jhfdd2h7oiirvygyoivpyq2ja (approved-copy-2): the first approval's \"You can still download one.\" promised a Download button the page doesn't have."}, |
| {"id": "backups.why.nothingyet", "file": "internal/console/instancecopy.go", "text": "Check back in a minute."}, |
| {"id": "backups.cli.summary", "file": "internal/console/instancecopy.go", "text": "Use the command line"}, |
| {"id": "backups.cli.latest", "file": "internal/console/instancecopy.go", "text": "The latest copy:"}, |
diff --git a/internal/console/instancecopy.go b/internal/console/instancecopy.go| index d1b7c9190..684eedaf5 100644 |
| --- a/internal/console/instancecopy.go |
| +++ b/internal/console/instancecopy.go |
| @@ -62,7 +62,7 @@ var backupsCopy = backupsCopyStrings{ |
| WhyDemo: "Demo data isn't kept.", |
| WhyPooled: "Copies of pooled instances aren't shown here yet.", |
| WhyFleet: "Copies on your own servers aren't shown here yet.", |
| - WhyOtherRegion: "Copies in {region} aren't shown here yet. You can still download one.", |
| + WhyOtherRegion: "Copies in {region} aren't shown here yet. Use the command line below to get one.", |
| WhyNothingYet: "Check back in a minute.", |
| CLISummary: "Use the command line", |
| CLILatest: "The latest copy:", |
diff --git a/internal/console/instancepage.go b/internal/console/instancepage.go| index b332cb760..2455976ad 100644 |
| --- a/internal/console/instancepage.go |
| +++ b/internal/console/instancepage.go |
| @@ -482,8 +482,11 @@ func (s *Server) instanceBackups(ctx context.Context, acct, app string, rt *Rout |
| } |
| v = s.backupsFor(ctx, provision.Record{Host: rt.Host, Kind: rt.Kind}) |
| case err != nil: |
| + // Without the record nothing is known about either row, born HA |
| + // included, so neither row claims anything. |
| log.Printf("console: instance page backups %s/%s/%s: %v", acct, app, rt.Host, err) |
| - v = backupsView{Class: backupNotShown, Reason: backupReasonUnavailable} |
| + c := backupsCopy |
| + return &backupsSection{DBChip: c.ChipUnavailable, DBTone: backupsToneNeutral, FilesChip: c.ChipUnavailable, FilesTone: backupsToneNeutral} |
| default: |
| v = s.backupsFor(ctx, *rec) |
| } |
diff --git a/internal/console/instancepage_test.go b/internal/console/instancepage_test.go| index d4c3419ec..f57e865a6 100644 |
| --- a/internal/console/instancepage_test.go |
| +++ b/internal/console/instancepage_test.go |
| @@ -22,6 +22,7 @@ import ( |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/regionlabel" |
| "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/status" |
| ) |
| @@ -291,7 +292,13 @@ func TestInstanceDetailShowsLayoutUnknownWithNoReport(t *testing.T) { |
| // signed in as the owner of kass. |
| func backupsPageFixture(t *testing.T, replicas map[string]replicaReader) (*consoleFixture, *http.Client) { |
| t.Helper() |
| - fx := newConsoleFixture(t) |
| + return backupsPageFixtureWith(t, consoleFixtureOptions{}, replicas) |
| +} |
| + |
| +// backupsPageFixtureWith is backupsPageFixture on newConsoleFixtureWith(o). |
| +func backupsPageFixtureWith(t *testing.T, o consoleFixtureOptions, replicas map[string]replicaReader) (*consoleFixture, *http.Client) { |
| + t.Helper() |
| + fx := newConsoleFixtureWith(t, o) |
| c := signInPaul(t, fx) |
| fx.srv.cfg.HibernateBucket = "data-test" |
| fx.srv.cfg.HibernatePrefix = "instances" |
| @@ -623,7 +630,7 @@ func TestInstancePageBackupsOtherRegion(t *testing.T) { |
| sec := backupsPage(t, fx, c, "far.carlosapp.dev") |
| for _, want := range []string{ |
| `<tr><td>Database</td><td><span class="chip chip-env">Not shown here</span></td></tr>`, |
| - `<p class="small">` + pageText("Copies in "+far+" aren't shown here yet. You can still download one.") + `</p>`, |
| + `<p class="small">` + pageText("Copies in "+far+" aren't shown here yet. Use the command line below to get one.") + `</p>`, |
| "<pre><code>carlos db pull --app kass --instance far.carlosapp.dev --out far.db</code></pre>", |
| "--at ", |
| } { |
| @@ -689,3 +696,44 @@ func TestInstancePageBackupsWithoutRecord(t *testing.T) { |
| t.Errorf("missing %q in %q", want, sec) |
| } |
| } |
| + |
| +// backupsUnreadStore fails every read of one key, as a bucket that can't be |
| +// reached right now does. |
| +type backupsUnreadStore struct { |
| + release.Store |
| + key string |
| +} |
| + |
| +func (s backupsUnreadStore) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + if key == s.key { |
| + return nil, "", errors.New("the bucket did not answer") |
| + } |
| + return s.Store.Get(ctx, key) |
| +} |
| + |
| +// TestInstancePageBackupsRecordUnread: when the instance's record can't be |
| +// read, nothing is known about either row (born HA or not, copied or not), |
| +// so both say "Can't read now", with no reason line, no tiles and no |
| +// command. Distinct from a replica listing that fails, where the record |
| +// was read and the files row is known. |
| +func TestInstancePageBackupsRecordUnread(t *testing.T) { |
| + key := provision.RecordKey(release.OpsAccount, "kass", "unread.carlosapp.dev") |
| + fx, c := backupsPageFixtureWith(t, consoleFixtureOptions{WrapReleases: func(s release.Store) release.Store { |
| + return backupsUnreadStore{Store: s, key: key} |
| + }}, nil) |
| + putBackupsHost(t, fx, provision.Record{Host: "unread.carlosapp.dev", HA: true}) |
| + sec := backupsPage(t, fx, c, "unread.carlosapp.dev") |
| + for _, want := range []string{ |
| + `<tr><td>Database</td><td><span class="chip chip-env">Can't read now</span></td></tr>`, |
| + `<tr><td>Files on disk</td><td><span class="chip chip-env">Can't read now</span></td></tr>`, |
| + } { |
| + if !strings.Contains(sec, want) { |
| + t.Errorf("missing %q in %s", want, sec) |
| + } |
| + } |
| + for _, bad := range []string{`<p class="small">`, "stat-tiles", "carlos db pull", "Not copied", "Not shown here"} { |
| + if strings.Contains(sec, bad) { |
| + t.Errorf("the section says %q without the record: %s", bad, sec) |
| + } |
| + } |
| +} |