{"record":{"id":"948be2a324754452","repo":"withastro/astro","slug":"unable-to-read-wrangler-config-variables-defined","errorCode":null,"errorMessage":"Unable to read wrangler config, variables defined in it will not be available to astro:env at build time.","messagePattern":"Unable to read wrangler config, variables defined in it will not be available to astro:env at build time\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/integrations/cloudflare/src/utils/wrangler-config.ts","lineNumber":68,"sourceCode":"\t\t\tconfig.configPath,\n\t\t\tundefined,\n\t\t\tconfig.vars,\n\t\t\tenv,\n\t\t\ttrue,\n\t\t\tconfig.secrets,\n\t\t);\n\n\t\tfor (const [key, binding] of Object.entries(vars)) {\n\t\t\t// `vars` can hold non-string JSON values (numbers, booleans, objects).\n\t\t\t// `process.env` only stores strings.\n\t\t\tconst value = binding.value;\n\t\t\tif (value === undefined || value === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprocess.env[key] = typeof value === 'string' ? value : JSON.stringify(value);\n\t\t}\n\t} catch (e) {\n\t\tlogger.warn(\n\t\t\t`Unable to read wrangler config, variables defined in it will not be available to astro:env at build time.`,\n\t\t);\n\t\tlogger.debug(String(e));\n\t}\n}\n","sourceCodeStart":50,"sourceCodeEnd":74,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/integrations/cloudflare/src/utils/wrangler-config.ts#L50-L74","documentation":"The Cloudflare adapter reads your wrangler config (wrangler.toml / wrangler.jsonc) to copy its `vars` entries into process.env so astro:env variables resolve at build time. The whole read runs in a try/catch; any throw — missing file, unreadable, invalid TOML/JSONC, unexpected shape — logs this warning and continues, with the original error only visible via logger.debug.","triggerScenarios":"The wrangler config is absent (never created, renamed, or not checked out in CI), syntactically invalid after editing bindings, or lives where the adapter does not look. Afterwards, every astro:env variable defined only in wrangler `vars` is undefined during the build.","commonSituations":"Renaming wrangler.toml to wrangler.jsonc mid-migration and leaving broken syntax; CI jobs that skip copying the config; developers who run builds without Wrangler installed and never validate the file.","solutions":["Create or repair the wrangler config at the project root and fix the syntax error","Confirm it parses with Wrangler itself: `npx wrangler deploy --dry-run --outdir /tmp/cf-dry` (or `npx wrangler types`) exits cleanly","Re-run with debug logging (e.g. ASTRO_LOG_LEVEL=debug) to see the swallowed exception","Mirror build-critical vars in properly scoped .env files so builds do not depend solely on wrangler config"],"exampleFix":"# before: wrangler.toml invalid (unclosed table)\nname = \"site\"\n[vars\nPUBLIC_API_URL = \"https://api.example.com\"\n\n# after: valid config\nname = \"site\"\ncompatibility_date = \"2025-01-01\"\n\n[vars]\nPUBLIC_API_URL = \"https://api.example.com\"","handlingStrategy":"validation","validationCode":"# Validate the wrangler config before building\nnpx wrangler types || npx wrangler deploy --dry-run --outdir /tmp/cf-dry-run","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep wrangler.toml / wrangler.jsonc valid at the repo root and lint it in CI with a Wrangler dry-run","Run builds with debug logging (ASTRO_LOG_LEVEL=debug) when vars seem missing — the parse error is only visible there","Mirror build-critical astro:env variables in scoped .env files instead of relying solely on wrangler config"],"tags":["cloudflare","wrangler","config","astro-env","environment-variables"],"backgroundTag":"config-file-read-failed","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}