console: app pages and actions work on a console with no bucket (#720)
Root cause: loadAppFrame read a nil store on every app page. Fixed there; bucket-dependent app POSTs are refused after membership and CSRF and before any store access (refuseAppNoBucket, guard test over every app POST route); LoadMetrics returns metrics-unavailable before any bucket work (Paul's stopping-rule-2 choice). Regression tests cover routed apps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from nobucket-panic-720 into main.
10 files changed,
+318
−67
internal/console/appframe.go+9 −0internal/console/appsettings_test.go+3 −7internal/console/envform_test.go+75 −15internal/console/metricsview.go+11 −0internal/console/nobucket_posts_test.go+98 −0internal/console/pendinghandlers.go+3 −0internal/console/pipelinepage.go+9 −0internal/console/reqmemo.go+10 −0internal/console/server.go+97 −45internal/console/templates/pipeline.html+3 −0
CI passed — run details
diff --git a/internal/console/appframe.go b/internal/console/appframe.go| index 2a6c6ba48..6247e711d 100644 |
| --- a/internal/console/appframe.go |
| +++ b/internal/console/appframe.go |
| @@ -104,8 +104,17 @@ func (f appFrame) clone() appFrame { |
| // pipelineStoreTimeout, as it always was). The three are independent and |
| // run at once, and the channels are read readConcurrency at a time, kept in |
| // name order. |
| +// |
| +// A console without a deployment bucket (Config.Releases nil) has none of |
| +// these objects, so its frame is the empty one: no channels, no production |
| +// flag, no pipeline. Every app page reads the frame, so this is the one |
| +// place a bucketless console must stop; the pages then say "no deployment |
| +// bucket" where a section needs one (#720). |
| func loadAppFrame(ctx context.Context, st release.Store, pub ed25519.PublicKey, acct, app string) appFrame { |
| var f appFrame |
| + if st == nil { |
| + return f |
| + } |
| runConcurrently( |
| func() { f.Channels, f.ChannelsErr = loadFrameChannels(ctx, st, pub, acct, app) }, |
| func() { |
diff --git a/internal/console/appsettings_test.go b/internal/console/appsettings_test.go| index 2934a3b2c..043ed1f37 100644 |
| --- a/internal/console/appsettings_test.go |
| +++ b/internal/console/appsettings_test.go |
| @@ -1117,13 +1117,9 @@ func TestSettingsPageShowsChannelFieldWhenOnlyRouteIsPlatform(t *testing.T) { |
| // would vanish from Settings.Domains the moment there was no bucket to |
| // check the never-shipped rename gate against. |
| // |
| -// This calls assembleSettings directly rather than through the HTTP page: |
| -// a bucketless console panics inside Assemble itself (assembleChannels, |
| -// view.go, calls release.Store.List on every app-page tab, Settings |
| -// included, with no nil guard) — a real, pre-existing gap, but one that |
| -// reaches every app page and is not Task 5's Settings-only bug. Fixing |
| -// assembleSettings's own early return is; isolating it here proves that fix |
| -// without the unit test tripping over the wider, separate one. |
| +// This calls assembleSettings directly, isolating its own early return. |
| +// The whole page on a bucketless console is TestNoBucketAppPagesRender |
| +// (envform_test.go; #720 fixed the app-frame panic it once hit). |
| func TestAssembleSettingsListsRoutedDomainsWithoutABucket(t *testing.T) { |
| fx := newConsoleFixture(t) |
| fx.srv.cfg.Releases = nil |
diff --git a/internal/console/envform_test.go b/internal/console/envform_test.go| index f347ee67d..a4cb3aba2 100644 |
| --- a/internal/console/envform_test.go |
| +++ b/internal/console/envform_test.go |
| @@ -257,22 +257,82 @@ func TestEnvSectionDefaultFirst(t *testing.T) { |
| check(true) |
| } |
| -// A console without a deployment bucket cannot assemble an app page at |
| -// all, so the section's no-bucket branch is drawn straight from the |
| -// template, as assembleSettings leaves the view: NoBucket and no editing. |
| -// The POST door says 409 for the same console shape (handleEnvForm). |
| -func TestEnvSectionReadOnlyForNoBucket(t *testing.T) { |
| +// A console without a deployment bucket (Config.Releases nil) renders every |
| +// app page through the real handlers (#720: they used to panic in the app |
| +// frame's bucket reads). The overview and each settings section answer 200, |
| +// the sections that need the bucket say so, the pipeline section shows no |
| +// form, and the environments section is read-only; its POST door refuses |
| +// with 409 and writes nothing. Every other app POST: TestNoBucketAppPostsRefuse. |
| +func TestNoBucketAppPagesRender(t *testing.T) { |
| fx := newConsoleFixture(t) |
| - p := page{Nav: "/a/shop", SettingsSection: "environments", Detail: &AppView{App: "sprout"}, Account: &Account{Name: "shop", Sqid: "bab"}, AppName: "sprout", |
| - Settings: &SettingsView{NoBucket: true}} |
| - rec := httptest.NewRecorder() |
| - fx.srv.render(rec, http.StatusOK, "app_settings", p) |
| - body := rec.Body.String() |
| - if rec.Code != http.StatusOK { |
| - t.Fatalf("render = %d:\n%s", rec.Code, body) |
| - } |
| - mustContain(t, body, "no deployment bucket on this host", "No named environments", "carlos env set --app sprout") |
| - mustNotContain(t, body, `/settings/environments"`, "data-secret-input", `class="savebar"`) |
| + freshApp(t, fx, "sprout") |
| + fx.srv.cfg.Releases = nil |
| + c := signInPaul(t, fx) |
| + |
| + banners := map[string]string{ |
| + "environments": "no deployment bucket on this host — this console cannot read config", |
| + "storage": "no deployment bucket on this host — this console cannot serve object storage", |
| + "email": "no deployment bucket on this host — this console cannot serve email", |
| + "features": "no deployment bucket on this host — this console cannot read features", |
| + "general": "No deployment bucket on this host, so the never-shipped check cannot run.", |
| + } |
| + paths := map[string]string{"overview": "/apps/sprout", "releases": "/apps/sprout/releases", "instances": "/apps/sprout/instances"} |
| + for section := range appSettingsSections { |
| + paths[section] = "/apps/sprout/settings/" + section |
| + } |
| + // sprout has no routes; kass (the fixture's) has owned routes, so its |
| + // pages also reach the metrics reader. |
| + for _, app := range []string{"sprout", "kass"} { |
| + for name, path := range paths { |
| + path = strings.Replace(path, "/apps/sprout", "/apps/"+app, 1) |
| + status, _, body := get(t, c, fx.u(path)) |
| + if status != http.StatusOK { |
| + t.Fatalf("%s %s on a bucketless console = %d:\n%s", app, name, status, body) |
| + } |
| + if want := banners[name]; want != "" { |
| + mustContain(t, body, want) |
| + } |
| + } |
| + } |
| + |
| + _, _, pipeBody := get(t, c, fx.u("/apps/sprout/settings/pipeline")) |
| + mustContain(t, pipeBody, banners["environments"]) |
| + mustNotContain(t, pipeBody, `value="save"`, `/apps/sprout/pipeline"`, "template-edge-production") |
| + |
| + _, _, envBody := get(t, c, fx.u("/apps/sprout/settings/environments")) |
| + mustContain(t, envBody, "No named environments", "carlos env set --app sprout") |
| + mustNotContain(t, envBody, "/settings/environments#after-save", "data-env-form", "data-secret-input", `class="savebar"`) |
| + |
| + f := url.Values{"csrf": {sessionToken(t, fx, c)}, "op": {"add:default"}, |
| + "add.default.name": {"MODE"}, "add.default.value": {"fast"}} |
| + status, _, body := postForm(t, c, fx.u("/apps/sprout/settings/environments"), f) |
| + if status != http.StatusConflict { |
| + t.Fatalf("env form POST on a bucketless console = %d, want 409:\n%s", status, body) |
| + } |
| + mustContain(t, body, banners["environments"]) |
| + mustNotContain(t, body, "MODE", "fast", `class="savebar"`) |
| +} |
| + |
| +// TestNoBucketRoutedAppMetricsPages: the three app pages that read box |
| +// metrics for an app's owned routes (Overview, Instances, one instance) |
| +// render on a bucketless console with a cold metrics cache, LoadMetrics |
| +// answering unavailable rather than listing a nil store (#720 round 2). |
| +func TestNoBucketRoutedAppMetricsPages(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fx.srv.cfg.Releases = nil |
| + c := signInPaul(t, fx) |
| + for name, path := range map[string]string{ |
| + "overview": "/apps/kass", |
| + "instances": "/apps/kass/instances", |
| + "instance": "/apps/kass/instances/kass.carlosapp.dev", |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + status, _, body := get(t, c, fx.u(path)) |
| + if status != http.StatusOK { |
| + t.Fatalf("%s = %d:\n%s", path, status, body) |
| + } |
| + }) |
| + } |
| } |
| func TestEnvFormCSRF(t *testing.T) { |
diff --git a/internal/console/metricsview.go b/internal/console/metricsview.go| index 90c3a77b9..09ec793c2 100644 |
| --- a/internal/console/metricsview.go |
| +++ b/internal/console/metricsview.go |
| @@ -299,7 +299,14 @@ type metricsCache struct { |
| // own context still governs WAITING in the blocking case (a cancelled |
| // waiter gives up rather than hanging), it just never governs the sweep |
| // itself. |
| +// |
| +// A console with no deployment bucket has no metrics to read: LoadMetrics |
| +// answers errMetricsNoBucket before the cache or any sweep, and every caller |
| +// shows metrics as unavailable through its ordinary error path (#720). |
| func (s *Server) LoadMetrics(ctx context.Context) ([]BoxMetricsView, []AlertRow, error) { |
| + if s.cfg.Releases == nil { |
| + return nil, nil, errMetricsNoBucket |
| + } |
| c := &s.metricsCache |
| for { |
| c.mu.Lock() |
| @@ -435,6 +442,10 @@ func (s *Server) startBackgroundSweep(c *metricsCache) { |
| }() |
| } |
| +// errMetricsNoBucket is LoadMetrics' answer on a console with no |
| +// deployment bucket. |
| +var errMetricsNoBucket = errors.New("console: no deployment bucket, so no metrics to read") |
| + |
| // sweepAll is the bucket half of LoadMetrics: discovery, every box's 48h raw |
| // sweep (metricsSweepBoxes of them at a time), then the alerts pass, on a |
| // context detached from the caller's (WithoutCancel) and bounded by |
diff --git a/internal/console/nobucket_posts_test.go b/internal/console/nobucket_posts_test.go| new file mode 100644 |
| index 000000000..be8b442fa |
| --- /dev/null |
| +++ b/internal/console/nobucket_posts_test.go |
| @@ -0,0 +1,98 @@ |
| +package console |
| + |
| +import ( |
| + "net/url" |
| + "sort" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// noBucketPostAllowed are the app POST routes that do not need the |
| +// deployment bucket, or that already refuse without one through their own |
| +// guard, each with why. Every other POST route under /a/{sqid}/apps/{app}/ |
| +// must answer refuseAppNoBucket's 503 on a bucketless console. |
| +var noBucketPostAllowed = map[string]string{ |
| + "POST /a/{sqid}/apps/{app}/analytics/setting": "own guard first: flash, no write (handleAppAnalyticsSetting)", |
| + "POST /a/{sqid}/apps/{app}/errors/level": "own guard first: flash, no write (handleAppErrorLevel)", |
| + "POST /a/{sqid}/apps/{app}/protection/setting": "own guard first: flash, no write (handleAppProtectionSetting)", |
| + "POST /a/{sqid}/apps/{app}/swap": "own guard first: swapCopy.NoBucket flash (handleAppSwap)", |
| + "POST /a/{sqid}/apps/{app}/gate": "own guard first: flash (handleAppGate)", |
| + "POST /a/{sqid}/apps/{app}/ratelimit": "own guard first: flash (handleAppRateLimit)", |
| + "POST /a/{sqid}/apps/{app}/rename": "own guard before the never-shipped read (handleAppRename)", |
| + "POST /a/{sqid}/apps/{app}/delete": "own guard before the production read (handleAppDelete)", |
| + "POST /a/{sqid}/apps/{app}/store/destroy": "own guard before the record read (handleStoreDestroy)", |
| + "POST /a/{sqid}/apps/{app}/settings/environments": "refuses 409 read-only: assembleSettings sets NoBucket, no edit (handleEnvForm)", |
| + "POST /a/{sqid}/apps/{app}/region": "appRegionChoices refuses 503 OptionsUnread without a bucket", |
| + "POST /a/{sqid}/apps/{app}/place": "placeAppTarget refuses without a bucket", |
| + "POST /a/{sqid}/apps/{app}/domains/attach": "attachDomain opens with bucketRefusal (503)", |
| + "POST /a/{sqid}/apps/{app}/domains/detach": "detachDomain and detachInstanceCatchall refuse without a bucket", |
| + "POST /a/{sqid}/apps/{app}/domains/buy": "domainPurchaseReady needs Releases, so the door is 404", |
| + "POST /a/{sqid}/apps/{app}/domains/check": "domainPurchaseReady needs Releases, so the door is 404", |
| + "POST /a/{sqid}/apps/{app}/restart": "handleBrowserRestart refuses before any restart without a bucket", |
| + "POST /a/{sqid}/apps/{app}/instances/{host}/restart": "handleBrowserRestart refuses before any restart without a bucket", |
| + "POST /a/{sqid}/apps/{app}/instances/{host}/retry": "own gate 404s without a bucket (handleInstanceRetry)", |
| + "POST /a/{sqid}/apps/{app}/instances/{host}/updates": "updatesFormGate 404s without a bucket", |
| + "POST /a/{sqid}/apps/{app}/instances/{host}/updates/install": "updatesFormGate 404s without a bucket", |
| + "POST /a/{sqid}/apps/{app}/move": "console database only; appPolicyState skips the bucket when there is none", |
| + "POST /a/{sqid}/apps/{app}/extend": "console database only; settleApp skips the bucket when there is none", |
| + "POST /a/{sqid}/apps/{app}/keep": "console database only; settleApp skips the bucket when there is none", |
| + "POST /a/{sqid}/apps/{app}/star": "console database only", |
| + "POST /a/{sqid}/apps/{app}/control-plane/clear": "console database only", |
| + "POST /a/{sqid}/apps/{app}/control-plane/set": "console database only", |
| + "POST /a/{sqid}/apps/{app}/pending/{id}/reject": "console database only", |
| +} |
| + |
| +// TestNoBucketAppPostsRefuse walks every registered POST route under |
| +// /a/{sqid}/apps/{app}/ on a console with no deployment bucket, as the |
| +// signed-in owner with a valid CSRF token and a minimal form (#720). None may |
| +// panic (the connection closing with EOF): with Config.Releases nil, any |
| +// bucket read or write would. A route not on noBucketPostAllowed must be |
| +// refused by refuseAppNoBucket: 503 and its message, before any store access. |
| +func TestNoBucketAppPostsRefuse(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + freshApp(t, fx, "sprout") |
| + fx.srv.cfg.Releases = nil |
| + c := signInPaul(t, fx) |
| + csrf := sessionToken(t, fx, c) |
| + |
| + var patterns []string |
| + for _, e := range fx.srv.claimEntries.snapshot() { |
| + if e.Kind == "route" && strings.HasPrefix(e.Pattern, "POST /a/{sqid}/apps/{app}/") { |
| + patterns = append(patterns, e.Pattern) |
| + } |
| + } |
| + sort.Strings(patterns) |
| + if len(patterns) < 30 { |
| + t.Fatalf("found %d app POST routes, want the full set: %v", len(patterns), patterns) |
| + } |
| + form := url.Values{ |
| + "csrf": {csrf}, "action": {"save"}, "op": {"add:default"}, |
| + "channel": {"stable"}, "version": {"v1"}, "name": {"test"}, "production": {"on"}, |
| + "ch.0.name": {"edge"}, |
| + } |
| + for _, pattern := range patterns { |
| + path := strings.TrimPrefix(pattern, "POST /a/{sqid}") |
| + path = strings.NewReplacer("{app}", "sprout", "{host}", "web.bab.example.com", "{id}", "1").Replace(path) |
| + resp, err := c.PostForm(fx.u(path), form) |
| + if err != nil { |
| + t.Errorf("%s: %v (the handler panicked)", pattern, err) |
| + continue |
| + } |
| + body := readBody(t, resp) |
| + if _, ok := noBucketPostAllowed[pattern]; ok { |
| + continue |
| + } |
| + if resp.StatusCode != 503 || !strings.Contains(body, doorKeyNoBucketMsg) { |
| + t.Errorf("%s = %d, want the no-bucket 503", pattern, resp.StatusCode) |
| + } |
| + } |
| + for pattern := range noBucketPostAllowed { |
| + found := false |
| + for _, p := range patterns { |
| + found = found || p == pattern |
| + } |
| + if !found { |
| + t.Errorf("noBucketPostAllowed names %s, which is not a registered app POST route", pattern) |
| + } |
| + } |
| +} |
diff --git a/internal/console/pendinghandlers.go b/internal/console/pendinghandlers.go| index 9e659a49c..c15250950 100644 |
| --- a/internal/console/pendinghandlers.go |
| +++ b/internal/console/pendinghandlers.go |
| @@ -716,6 +716,9 @@ func (s *Server) handlePendingConfirm(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Confirmations disabled", |
| "No signing key on this host — the console is running read-only.") |
diff --git a/internal/console/pipelinepage.go b/internal/console/pipelinepage.go| index 295284fad..22de0c73d 100644 |
| --- a/internal/console/pipelinepage.go |
| +++ b/internal/console/pipelinepage.go |
| @@ -217,6 +217,12 @@ func (s *Server) writePipeline(ctx context.Context, acct *Account, app string, c |
| // same as the rest of the app's settings tab. |
| func (s *Server) handlePipelineSettingsPage(w http.ResponseWriter, r *http.Request, p page, acct *Account) { |
| setAppSettingsSection(&p, "pipeline") |
| + if s.cfg.Releases == nil { |
| + // No bucket (#720): nothing to read and nowhere to save, so no form. |
| + p.PipelineNoBucket = true |
| + s.render(w, http.StatusOK, "pipeline_settings", p) |
| + return |
| + } |
| channels := release.DefaultPipelineChannels() |
| if p.Detail.PipelineErr != "" { |
| log.Printf("console: pipeline settings %s/%s: %s", acct.Sqid, p.AppName, p.Detail.PipelineErr) |
| @@ -268,6 +274,9 @@ func (s *Server) handlePipelineSettingsSave(w http.ResponseWriter, r *http.Reque |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| addr, raw, app := p.Address, p.CSRF, p.AppName |
| rows := parsePipelineRows(r) |
diff --git a/internal/console/reqmemo.go b/internal/console/reqmemo.go| index 124494b63..e518be248 100644 |
| --- a/internal/console/reqmemo.go |
| +++ b/internal/console/reqmemo.go |
| @@ -206,6 +206,10 @@ func (s *Server) loadBoxes(ctx context.Context, st release.Store, prefix string) |
| return l.boxes[:len(l.boxes):len(l.boxes)], l.complete, err |
| } |
| +// errLiveEdgesNoBucket is liveEdges' answer on a console with no |
| +// deployment bucket. |
| +var errLiveEdgesNoBucket = errors.New("console: no deployment bucket, so no edges to read") |
| + |
| // liveEdges is the one read every automatic-eligibility caller makes: the |
| // edges files joined with box liveness as of now (F1), once per request. |
| // The edges files and the box reports are read at once, each fan-out |
| @@ -214,7 +218,13 @@ func (s *Server) loadBoxes(ctx context.Context, st release.Store, prefix string) |
| // (console-slow-writes). Only the box reports are read when the edges |
| // files would not list, as that read made them after; the answer is still |
| // the listing's error. |
| +// |
| +// A console with no deployment bucket has no edges files to read: the |
| +// answer is errLiveEdgesNoBucket, which every caller treats as unread (#720). |
| func (s *Server) liveEdges(ctx context.Context) (edgesSnapshot, error) { |
| + if s.cfg.Releases == nil { |
| + return edgesSnapshot{}, errLiveEdgesNoBucket |
| + } |
| return memoize(ctx, "edges", func() (edgesSnapshot, error) { |
| now := time.Now() |
| var ( |
diff --git a/internal/console/server.go b/internal/console/server.go| index 350057867..797b15c9e 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -2632,6 +2632,10 @@ type page struct { |
| // The pipeline settings page (pipelinepage.go), GET |
| // /a/{sqid}/apps/{app}/settings/pipeline and POST .../pipeline: |
| + // PipelineNoBucket: the console has no deployment bucket, so the |
| + // pipeline cannot be read or saved; the section shows the no-bucket |
| + // banner and no form (#720). |
| + PipelineNoBucket bool |
| // PipelineRows is the current (or mid-edit draft) channel list as |
| // editable form rows, indexed ch.<i>.*; PipelineIsDefault is whether |
| // it's still the untouched one-channel default a fresh app is created |
| @@ -4480,6 +4484,24 @@ func (s *Server) accountApp(w http.ResponseWriter, r *http.Request) (addr, raw s |
| return addr, raw, acct, role, app, true |
| } |
| +// refuseAppNoBucket is the one no-bucket refusal for a browser app action |
| +// that reads or writes the deployment bucket (#720). A console running |
| +// without one (Config.Releases nil) has none of the objects such an action |
| +// touches, so the action is refused with 503 and nothing is read or written. |
| +// |
| +// Callers place it after their session, membership (accountApp or appPage) |
| +// and CSRF gates and before their first store access; at a door that also |
| +// asks for a fresh passkey, before requireFreshAuth, which needs no store |
| +// either. It reports whether it refused. TestNoBucketAppPostsRefuse walks |
| +// every app POST route to hold the rule. |
| +func (s *Server) refuseAppNoBucket(w http.ResponseWriter, r *http.Request) bool { |
| + if s.cfg.Releases != nil { |
| + return false |
| + } |
| + s.renderMessage(w, r, http.StatusServiceUnavailable, "Refused", doorKeyNoBucketMsg) |
| + return true |
| +} |
| + |
| // appPage gates an app page, assembles its platform view, and fills the |
| // chrome every app tab shares. Callers add their own tab's data on top. |
| func (s *Server) appPage(w http.ResponseWriter, r *http.Request, tab string) (page, *Account, bool) { |
| @@ -4686,12 +4708,17 @@ func (s *Server) handleApp(w http.ResponseWriter, r *http.Request) { |
| } |
| traffic <- &win |
| }() |
| - versions, err := Versions(r.Context(), s.cfg.Releases, acct.Sqid, app) |
| - if err != nil { |
| - log.Printf("console: versions %s: %v", app, err) |
| - p.FlashErr = "Could not list this app's releases." |
| + // No deployment bucket (#720): no releases to list, and nothing failed. |
| + var versions []VersionView |
| + if s.cfg.Releases != nil { |
| + var err error |
| + versions, err = Versions(r.Context(), s.cfg.Releases, acct.Sqid, app) |
| + if err != nil { |
| + log.Printf("console: versions %s: %v", app, err) |
| + p.FlashErr = "Could not list this app's releases." |
| + } |
| + p.Versions = versions |
| } |
| - p.Versions = versions |
| metrics := s.appResourceMetrics(r.Context(), p.Detail, acct) |
| // The Database tile's sizes are best-effort: a slow status read costs the |
| // tile its number (the em-dash), never the page. |
| @@ -4785,48 +4812,52 @@ func (s *Server) handleAppReleases(w http.ResponseWriter, r *http.Request) { |
| p.ReleaseSummary = assembleReleaseSummary(p.Detail.Channels, p.Detail.Routes, acct.Sqid) |
| p.PromoteChannels = promoteChannelOptions(p.Detail.Channels, p.Detail.Pipeline) |
| p.VersionsPageNum = versionsPageParam(r) |
| - versions, newest, more, err := versionsPage(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName, p.VersionsPageNum) |
| - if err != nil { |
| - log.Printf("console: versions %s: %v", p.AppName, err) |
| - p.FlashErr = "Could not list this app's releases." |
| - } |
| - p.VersionsMore = more |
| - p.CanaryVersions = newest |
| - // Versions itself never reads ListTags (view.go), and neither does |
| - // assembleChannels any more — a full tag sweep thrown away by every |
| - // OTHER app-page tab and the account home page's whole app list would |
| - // be a needless read on every one of those renders (release versioning |
| - // spec, 2026-08-08; view.go's tagByRelease doc comment has the full |
| - // story). This tab is the one place that sweep pays for itself: ONE |
| - // ListTags read serves the Tags section below (raw records, changelog |
| - // and all, capped at tagsCap — ListTags' own semver-descending order), |
| - // the Releases table's pill (view.go's tagIndex, the pure fold with no |
| - // read of its own), and the Channels table's pill, backfilled onto |
| - // Assemble's already-built ChannelView rows since assembleChannels |
| - // itself leaves Tag "". A failed read degrades this tab's tag |
| - // decoration only; the page still renders. |
| - if tags, terr := release.ListTags(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName); terr != nil { |
| - log.Printf("console: tags %s: %v", p.AppName, terr) |
| - } else { |
| - byRelease := tagIndex(tags) |
| - for i := range versions { |
| - versions[i].Tag = byRelease[versions[i].Version] |
| - } |
| - for i := range p.Detail.Channels { |
| - p.Detail.Channels[i].Tag = byRelease[p.Detail.Channels[i].Version] |
| + // No deployment bucket (#720): no versions, tags or retention to read, |
| + // and nothing failed, so the tab draws its empty states. |
| + if s.cfg.Releases != nil { |
| + versions, newest, more, err := versionsPage(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName, p.VersionsPageNum) |
| + if err != nil { |
| + log.Printf("console: versions %s: %v", p.AppName, err) |
| + p.FlashErr = "Could not list this app's releases." |
| + } |
| + p.VersionsMore = more |
| + p.CanaryVersions = newest |
| + // Versions itself never reads ListTags (view.go), and neither does |
| + // assembleChannels any more — a full tag sweep thrown away by every |
| + // OTHER app-page tab and the account home page's whole app list would |
| + // be a needless read on every one of those renders (release versioning |
| + // spec, 2026-08-08; view.go's tagByRelease doc comment has the full |
| + // story). This tab is the one place that sweep pays for itself: ONE |
| + // ListTags read serves the Tags section below (raw records, changelog |
| + // and all, capped at tagsCap — ListTags' own semver-descending order), |
| + // the Releases table's pill (view.go's tagIndex, the pure fold with no |
| + // read of its own), and the Channels table's pill, backfilled onto |
| + // Assemble's already-built ChannelView rows since assembleChannels |
| + // itself leaves Tag "". A failed read degrades this tab's tag |
| + // decoration only; the page still renders. |
| + if tags, terr := release.ListTags(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName); terr != nil { |
| + log.Printf("console: tags %s: %v", p.AppName, terr) |
| + } else { |
| + byRelease := tagIndex(tags) |
| + for i := range versions { |
| + versions[i].Tag = byRelease[versions[i].Version] |
| + } |
| + for i := range p.Detail.Channels { |
| + p.Detail.Channels[i].Tag = byRelease[p.Detail.Channels[i].Version] |
| + } |
| + if len(tags) > tagsCap { |
| + tags = tags[:tagsCap] |
| + } |
| + p.Tags = tags |
| } |
| - if len(tags) > tagsCap { |
| - tags = tags[:tagsCap] |
| + p.Versions = versions |
| + // Read-only in v1: the policy is set via `carlos releases retention`; |
| + // this line just keeps the page honest about why old versions vanish. |
| + if ret, err := release.GetRetention(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName); err != nil { |
| + log.Printf("console: retention %s: %v", p.AppName, err) |
| + } else if ret != nil { |
| + p.RetentionKeep = ret.Keep |
| } |
| - p.Tags = tags |
| - } |
| - p.Versions = versions |
| - // Read-only in v1: the policy is set via `carlos releases retention`; |
| - // this line just keeps the page honest about why old versions vanish. |
| - if ret, err := release.GetRetention(r.Context(), s.cfg.Releases, acct.Sqid, p.AppName); err != nil { |
| - log.Printf("console: retention %s: %v", p.AppName, err) |
| - } else if ret != nil { |
| - p.RetentionKeep = ret.Keep |
| } |
| // The "how do I give this a URL" copy — not shared chrome (it's computed |
| // per app page, not carried by appPage), but the same fill the Instances |
| @@ -5916,6 +5947,9 @@ func (s *Server) handlePromote(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Promotions disabled", |
| "No signing key on this host — the console is running read-only.") |
| @@ -6186,6 +6220,9 @@ func (s *Server) handleRollback(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Promotions disabled", |
| "No signing key on this host — the console is running read-only.") |
| @@ -6366,6 +6403,9 @@ func (s *Server) handleProduction(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Promotions disabled", |
| "No signing key on this host — the console is running read-only.") |
| @@ -6435,6 +6475,9 @@ func (s *Server) handleFastTrack(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Promotions disabled", |
| "No signing key on this host — the console is running read-only.") |
| @@ -6677,6 +6720,9 @@ func (s *Server) handleNewCanary(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Promotions disabled", |
| "No signing key on this host — the console is running read-only.") |
| @@ -6788,6 +6834,9 @@ func (s *Server) handleNewCanary(w http.ResponseWriter, r *http.Request) { |
| // of a transient bucket error sends them at a door that will refuse them. |
| // Unreadable therefore renders the neutral form, never the enable step. |
| func (s *Server) instanceDomainFor(ctx context.Context, sqid, app string) (domain string, absent bool) { |
| + if s.cfg.Releases == nil { |
| + return "", false // no bucket (#720): nothing read, so nothing proven absent |
| + } |
| m, err := s.instancesManifest(ctx, sqid, app) |
| switch { |
| case err == nil: |
| @@ -6843,6 +6892,9 @@ func (s *Server) handleRetireCanary(w http.ResponseWriter, r *http.Request) { |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return |
| } |
| + if s.refuseAppNoBucket(w, r) { |
| + return |
| + } |
| if s.cfg.Key == nil { |
| s.renderMessage(w, r, http.StatusServiceUnavailable, "Promotions disabled", |
| "No signing key on this host — the console is running read-only.") |
diff --git a/internal/console/templates/pipeline.html b/internal/console/templates/pipeline.html| index dea50e7d6..bc53c3553 100644 |
| --- a/internal/console/templates/pipeline.html |
| +++ b/internal/console/templates/pipeline.html |
| @@ -14,6 +14,8 @@ |
| to confirm before a promotion onto it, or an edit to it, lands. One channel needs none of |
| this at all — the vocabulary only shows up once you add a second.</p> |
| +{{if .PipelineNoBucket}}<p class="banner error">no deployment bucket on this host — this console cannot read config</p> |
| +{{else}} |
| {{if .PipelineIsDefault}} |
| <div class="tiles"> |
| <form method="post" action="{{.Base}}/apps/{{.AppName}}/pipeline" class="inline"> |
| @@ -58,6 +60,7 @@ from scratch with the row below. Nothing is written until you press Save.</p> |
| <button type="submit" name="action" value="add" class="btn-sm">Add channel</button> |
| <button type="submit" name="action" value="save" class="btn">Save</button> |
| </form> |
| +{{end}} |
| <p class="small">Promoting into a channel with rules follows the order above; <code>-hotfix</code> |
| bypasses the order but never the rules. An edit that touches a channel the SAVED pipeline |
| already guards with change approvals becomes a proposal here too, at the quorum that channel |