console: refuse bucket app actions with no deployment bucket
#720 Astra round 1. Promote, rollback, production, fasttrack, canary, canary/retire, the pipeline Save and pending confirm reached a nil release.Store and panicked on a console with Config.Releases nil. One helper, refuseAppNoBucket, now refuses each with 503 and the existing doorKeyNoBucketMsg, after session, membership and CSRF and before any store access or requireFreshAuth. The pipeline settings section shows the existing no-bucket banner and no form. TestNoBucketAppPostsRefuse walks every registered app POST route on a bucketless console: none may panic, and each not on the allow list (own guard or console database only, each with its reason) must answer the helper's 503.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/envform_test.go+7 −2internal/console/nobucket_posts_test.go+98 −0internal/console/pendinghandlers.go+3 −0internal/console/pipelinepage.go+9 −0internal/console/server.go+40 −0internal/console/templates/pipeline.html+3 −0
CI passed — run details
Intent
<task-notification> <task-id>bnp4omzfp</task-id> <tool-use-id>toolu_01WZKnP9rPPHWu2MUNHuQanh</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/abe35d56-e4c2-40df-9005-6e66b76b1f50/tasks/bnp4omzfp.output</output-file> <status>completed</status> <summary>Background command "N=/home/paulca/amadan.net/carlos/platform/.claude/worktrees/followups-notes; until [ -f $N/astra-720.done ]; do sleep 30; done; grep -E "READY|^##|^### " $N/astra-720-findings.md | head -20; amadan ci status carlos/platform -branch mockup-whitespace-722 2>&1 | head -1" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 28.6 g CO₂e (3,724,502 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on nobucket-panic-720, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/console/envform_test.go b/internal/console/envform_test.go| index 0ad4840dc..668c3a8fb 100644 |
| --- a/internal/console/envform_test.go |
| +++ b/internal/console/envform_test.go |
| @@ -260,8 +260,9 @@ func TestEnvSectionDefaultFirst(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, and the environments section is |
| -// read-only; its POST door refuses with 409 and writes nothing. |
| +// 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) |
| freshApp(t, fx, "sprout") |
| @@ -289,6 +290,10 @@ func TestNoBucketAppPagesRender(t *testing.T) { |
| } |
| } |
| + _, _, 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"`) |
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/server.go b/internal/console/server.go| index 01f72f926..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) { |
| @@ -5925,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.") |
| @@ -6195,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.") |
| @@ -6375,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.") |
| @@ -6444,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.") |
| @@ -6686,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.") |
| @@ -6855,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 |