{"record":{"id":"f34ba708036e9d7d","repo":"sveltejs/kit","slug":"cannot-build-with-json-stringify-file-because-f34ba7","errorCode":null,"errorMessage":"Cannot build with ${JSON.stringify(file)} because Bun treats a route segment starting with `:` as a parameter. Rename the file or route so no segment starts with `:`.","messagePattern":"Cannot build with (.+?) because Bun treats a route segment starting with `:` as a parameter\\. Rename the file or route so no segment starts with `:`\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-bun/index.js","lineNumber":95,"sourceCode":"\tif (precompress) {\n\t\tif (fs.existsSync(`${file}.br`)) meta.br = true;\n\t\tif (fs.existsSync(`${file}.gz`)) meta.gz = true;\n\t}\n\n\treturn meta;\n}\n\n/** @param {string[]} files */\nfunction validate_file_paths(files) {\n\tfor (const file of files) {\n\t\tif (file.includes('*')) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot build with ${JSON.stringify(file)} because Bun treats literal \\`*\\` characters in route paths as wildcards. Rename the file or route to remove the \\`*\\` character.`\n\t\t\t);\n\t\t}\n\t\t// a leading ':' would need percent-encoding, but browsers request the colon raw\n\t\tif (file.split('/').some((segment) => segment.startsWith(':'))) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot build with ${JSON.stringify(file)} because Bun treats a route segment starting with \\`:\\` as a parameter. Rename the file or route so no segment starts with \\`:\\`.`\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** @type {import('./index.js').default} */\nexport default function (opts = {}) {\n\tconst {\n\t\tout = 'build',\n\t\tenvPrefix = '',\n\t\tprecompress = false,\n\t\tserverOptions = {},\n\t\tbuildOptions = {}\n\t} = opts;\n\n\treturn {\n\t\tname: '@sveltejs/adapter-bun',","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-bun/index.js#L77-L113","documentation":"adapter-bun rejects route paths where any segment starts with ':' because Bun's router treats a leading colon as a dynamic parameter placeholder, which would collide with the literal colon in the emitted file path (and browsers request the colon raw, unencoded).","triggerScenarios":"validate_file_paths splits the generated route file path on '/' and any segment begins with ':', e.g. a file/folder literally named ':id' under src/routes.","commonSituations":"A route directory or file accidentally named with a leading colon (e.g. src/routes/:id/+page.svelte) instead of SvelteKit's bracket syntax [id]; route folder names copied from another framework (Express/Next.js ':param' style).","solutions":["Rename the segment to SvelteKit's dynamic route syntax: src/routes/[id]/ instead of src/routes/:id/.","Audit src/routes for any file or folder whose name starts with ':'.","Use a different adapter (e.g. adapter-node) if ':'-prefixed paths are genuinely required."],"exampleFix":"// before\nsrc/routes/:id/+page.svelte\n// after\nsrc/routes/[id]/+page.svelte","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nconst bad = [];\n(function walk(dir) {\n  for (const seg of fs.readdirSync(dir)) {\n    const p = path.join(dir, seg);\n    if (fs.statSync(p).isDirectory()) {\n      if (seg.startsWith(':')) bad.push(p);\n      walk(p);\n    }\n  }\n})('src/routes');\nif (bad.length) throw new Error(`Rename ':'-prefixed route segments: ${bad.join(', ')}`);","typeGuard":"const isBunSafeRoute = (file) => !file.split('/').some((s) => s.startsWith(':'));","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (/segment starting with `:` as a parameter/.test(e.message)) {\n    console.error('Convert :x route segments to [x] SvelteKit bracket syntax');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Use [param] brackets, never ':param' folders, in src/routes","Grep the routes tree for ':'-prefixed names before building","Don't copy route folder names from Express/Next.js conventions"],"tags":["bun","routing","adapter-bun"],"backgroundTag":"invalid-route-path","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}