From 6ece225d196f5c9d049a37f7afb083de74cb6178 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 09:10:33 +0000 Subject: [PATCH] fix(cms): deploy without wrangler's R2 provisioning check (stack-tectonic 0.21.0) The PC4 merge's deploy (main run 40659792149) failed on stage and prod at `wrangler deploy`: wrangler 4 provisions resources by default and, for the new R2_MEDIA binding, read /r2/buckets/ with the brokered workers-deploy token, which has no R2 permission ("Authentication error [code: 10000]"). Terraform (cloudflare-r2-cms) already owns the bucket. stack-tectonic 0.21.0 adds `skipResourceProvisioning`, which passes --x-provision=false to the deploy. The CMS sets it, and the pin moves from 0.20.0 to 0.21.0. Nothing else in the move touches this repository: 0.20.1 fixed turbo-package's command guards, but 26 of the 27 turbo-package components subscribe on quick-check, which runs none of those steps, and the one on verify (tests/cms) declares no commands. Orun-Task: PC-7 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013JuHbkZCjDrGgHdzCrCRqG --- apps/cms/component.yaml | 8 +++++++- apps/cms/docs/runbook.md | 6 ++++++ intent.yaml | 2 +- tasks/PC-7.TaskContract.yaml | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/cms/component.yaml b/apps/cms/component.yaml index 1bdb859..35e0fcb 100644 --- a/apps/cms/component.yaml +++ b/apps/cms/component.yaml @@ -103,10 +103,16 @@ spec: wiringComponents: "cloudflare-hyperdrive-cms,cloudflare-r2-cms" wiringEnvs: "stage,prod" wiringFixture: wiring.fixture.json + # Terraform owns every resource the bindings name (cloudflare-r2-cms, + # cloudflare-hyperdrive-cms). Left on, wrangler reads the R2 bucket over + # the R2 API before the upload, and the brokered workers-deploy token has + # no R2 permission: "Authentication error [code: 10000]" on + # /r2/buckets/. The deploy step passes --x-provision=false. + skipResourceProvisioning: true installCommand: pnpm install --frozen-lockfile # The CMS's suite (tests/cms) runs in this lane too: a change to apps/cms # alone does not mark cms-tests changed (dependsOn orders, it does not - # propagate changes), and 0.20.0's worker composition has no test step. + # propagate changes), and the stack's worker composition has no test step. buildCommand: pnpm exec turbo run build --filter=@saas/cms && pnpm --filter @saas/cms-tests test typecheckCommand: pnpm exec turbo run typecheck --filter=@saas/cms dryRunCommand: pnpm exec wrangler deploy --dry-run --config wrangler.jsonc --env prod diff --git a/apps/cms/docs/runbook.md b/apps/cms/docs/runbook.md index 09fe384..ff03838 100644 --- a/apps/cms/docs/runbook.md +++ b/apps/cms/docs/runbook.md @@ -109,6 +109,12 @@ real R2 adapter. - `{"db":"error"}`: Payload started but the query failed: check that `cloudflare-hyperdrive-cms` applied, that the deploy rendered the right `HYPERDRIVE_CMS` id, and that db-migrate applied migration 200. +- **Deploy: "Authentication error [code: 10000]" on `/r2/buckets/`.** + Wrangler's resource provisioning checked the bucket with the brokered + `workers-deploy` token, which has no R2 permission. `skipResourceProvisioning: + true` in `component.yaml` turns that check off (stack-tectonic 0.21.0 and + later); check it is still set and the stack pin in `intent.yaml` has not + gone back below 0.21.0. The bucket itself comes from `cloudflare-r2-cms`. - **Uploads fail with "R2_MEDIA binding is missing".** The deploy rendered no `R2_MEDIA` binding: check that `cloudflare-r2-cms` applied for that environment and published `WIRING_CLOUDFLARE_R2_CMS`, then redeploy the CMS. diff --git a/intent.yaml b/intent.yaml index d35a46d..d7c9956 100644 --- a/intent.yaml +++ b/intent.yaml @@ -50,7 +50,7 @@ compositions: # a commit here. Bumping the tag is the deliberate upgrade step. - name: stack-tectonic kind: oci - ref: oci://ghcr.io/sourceplane/stack-tectonic:0.20.0 + ref: oci://ghcr.io/sourceplane/stack-tectonic:0.21.0 resolution: precedence: - stack-tectonic diff --git a/tasks/PC-7.TaskContract.yaml b/tasks/PC-7.TaskContract.yaml index e1a9a5b..08ba9bb 100644 --- a/tasks/PC-7.TaskContract.yaml +++ b/tasks/PC-7.TaskContract.yaml @@ -14,6 +14,8 @@ spec: - "pnpm-lock.yaml" - "infra/terraform/cloudflare-r2-cms/docs/**" - "tasks/PC-7.TaskContract.yaml" + # The stack pin: 0.21.0 lets the CMS deploy skip wrangler's R2 check. + - "intent.yaml" deps: - "PC-5" doneWhen: