{"record":{"id":"8be7e280b18b213a","repo":"sveltejs/kit","slug":"failed-to-parse-netlify-toml-err-message","errorCode":null,"errorMessage":"Failed to parse netlify.toml: ${err.message}","messagePattern":"Failed to parse netlify\\.toml: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-netlify/index.js","lineNumber":225,"sourceCode":"\t// Copy user's custom _redirects file if it exists\n\tif (existsSync('_redirects')) {\n\t\tbuilder.log.minor('Copying user redirects...');\n\t\tconst redirects_file = join(publish, '_redirects');\n\t\tbuilder.copy('_redirects', redirects_file);\n\t}\n}\n\n/**\n * @returns {NetlifyConfig | null}\n */\nfunction get_netlify_config() {\n\tif (!existsSync('netlify.toml')) return null;\n\n\ttry {\n\t\treturn parse(readFileSync('netlify.toml', 'utf-8'));\n\t} catch (err) {\n\t\tif (err instanceof Error) {\n\t\t\tthrow new Error(`Failed to parse netlify.toml: ${err.message}`, { cause: err });\n\t\t}\n\t\tthrow err;\n\t}\n}\n\n/**\n * Writes the Netlify Frameworks API config file\n * https://docs.netlify.com/build/frameworks/frameworks-api/\n * @param {{ builder: import('@sveltejs/kit').Builder }} params\n */\nfunction write_frameworks_config({ builder }) {\n\t// https://docs.netlify.com/build/frameworks/frameworks-api/#headers\n\t/** @type {{ headers: Array<{ for: string, values: Record<string, string> }> }} */\n\tconst config = {\n\t\theaders: [\n\t\t\t{\n\t\t\t\tfor: `/${builder.getAppPath()}/immutable/*`,\n\t\t\t\tvalues: {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-netlify/index.js#L207-L243","documentation":"adapter-netlify reads netlify.toml at build time to learn your build.publish and functions directories. If the TOML is syntactically invalid, the parser fails and the adapter rethrows with 'Failed to parse netlify.toml:' plus the underlying parser message (original error attached as cause).","triggerScenarios":"Running the Netlify adapter build with a netlify.toml in the project root that the @iarna/toml parser cannot parse (syntax error, unquoted strings with special chars, bad indentation, duplicate keys).","commonSituations":"Hand-edited netlify.toml with a missing quote or wrong indentation; merge conflicts partially resolved; copying config with smart quotes from documentation or chat.","solutions":["Read the underlying err.message/cause to find the offending line and fix the TOML syntax","Validate netlify.toml with a TOML linter or `npx netlify-cli` before building","Temporarily delete netlify.toml to confirm it is the parse failure source, then rebuild it cleanly"],"exampleFix":"// before (netlify.toml)\n[build]\npublish = \"build\"\nfunctions = 'functions\" // broken quote\n// after\n[build]\npublish = \"build\"\nfunctions = \"functions\"","handlingStrategy":"try-catch","validationCode":"import { parse } from '@iarna/toml';\nimport { readFileSync, existsSync } from 'node:fs';\nif (existsSync('netlify.toml')) parse(readFileSync('netlify.toml', 'utf-8')); // throws early if invalid","typeGuard":null,"tryCatchPattern":"try {\n  await vite.build();\n} catch (e) {\n  if (e.message.startsWith('Failed to parse netlify.toml')) {\n    console.error('TOML syntax error:', e.cause?.message);\n  }\n  throw e;\n}","preventionTips":["Run a TOML linter on netlify.toml in CI","Avoid hand-editing raw TOML under time pressure; use the Netlify CLI to modify config","Beware smart quotes and unescaped characters pasted from docs"],"tags":["config","toml","netlify","parse-error"],"backgroundTag":"config-parse-failed","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}