{"record":{"id":"87e18ee99604fde4","repo":"anomalyco/sst","slug":"errcloudflaremissingaccount","errorCode":"ErrCloudflareMissingAccount","errorMessage":"missing account","messagePattern":"missing account","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/project/provider/cloudflare.go","lineNumber":28,"sourceCode":"\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"sync\"\n\t_ \"unsafe\"\n\n\tcloudflare \"github.com/cloudflare/cloudflare-go\"\n\t\"github.com/sst/sst/v3/internal/util\"\n)\n\ntype CloudflareProvider struct {\n\tapi              *cloudflare.API\n\tidentifier       *cloudflare.ResourceContainer\n\tdefaultAccountId string\n}\n\nvar ErrCloudflareMissingAccount = fmt.Errorf(\"missing account\")\n\nfunc (c *CloudflareProvider) Env() (map[string]string, error) {\n\treturn map[string]string{\n\t\t\"CLOUDFLARE_DEFAULT_ACCOUNT_ID\": c.defaultAccountId,\n\t}, nil\n}\n\nfunc (c *CloudflareProvider) Init(app, stage string, args map[string]interface{}) error {\n\tapiToken := os.Getenv(\"CLOUDFLARE_API_TOKEN\")\n\tapiKey := os.Getenv(\"CLOUDFLARE_API_KEY\")\n\temail := os.Getenv(\"CLOUDFLARE_EMAIL\")\n\tif args[\"apiToken\"] != nil {\n\t\tapiToken = args[\"apiToken\"].(string)\n\t}\n\tif args[\"apiKey\"] != nil {\n\t\tapiKey = args[\"apiKey\"].(string)\n\t}\n\tif args[\"email\"] != nil {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/project/provider/cloudflare.go#L10-L46","documentation":"`ErrCloudflareMissingAccount` is returned by the Cloudflare provider's `Init` when no Cloudflare account ID can be resolved for the provider. The provider needs an account to scope resource containers (`identifier`) and exports `CLOUDFLARE_DEFAULT_ACCOUNT_ID`.","triggerScenarios":"Configuring the Cloudflare provider without `accountId` in the sst.config.ts provider block and without `CLOUDFLARE_ACCOUNT_ID` in the environment; an API token lacking permission to list accounts so auto-detection fails.","commonSituations":"Using a user-scoped API token instead of an account-scoped one; forgetting to set `accountId` when the token belongs to multiple accounts.","solutions":["Set `accountId` in the Cloudflare provider config in `sst.config.ts`","Or export `CLOUDFLARE_ACCOUNT_ID` in your shell/CI environment","Use an API token with the Account:Read permission so the account can be discovered"],"exampleFix":"// before\nprovider: {\n  cloudflare: { apiToken: process.env.CLOUDFLARE_API_TOKEN }\n}\n// after\nprovider: {\n  cloudflare: { apiToken: process.env.CLOUDFLARE_API_TOKEN, accountId: \"your-account-id\" }\n}","handlingStrategy":"validation","validationCode":"if (!process.env.CLOUDFLARE_ACCOUNT_ID && !sst.config()?.provider?.cloudflare?.accountId) {\n  throw new Error(\"Set cloudflare accountId in sst.config.ts or CLOUDFLARE_ACCOUNT_ID in the environment\");\n}","typeGuard":"function hasCloudflareAccount(cfg: { accountId?: string }): boolean {\n  return typeof cfg.accountId === \"string\" && cfg.accountId.length > 0;\n}","tryCatchPattern":"try {\n  await sst.deploy()\n} catch (e) {\n  if (String(e).includes(\"missing account\")) {\n    console.error(\"Set CLOUDFLARE_ACCOUNT_ID or provider accountId\");\n  }\n}","preventionTips":["Always set accountId in the cloudflare provider block for CI reproducibility","Use an account-scoped API token with Account:Read permission","Export CLOUDFLARE_ACCOUNT_ID in local shells and CI"],"tags":["cloudflare","config","account-id","init"],"backgroundTag":"missing-env-var","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}