{"record":{"id":"b047ebb53ab7b986","repo":"sveltejs/kit","slug":"cannot-build-with-json-stringify-file-because","errorCode":null,"errorMessage":"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.","messagePattern":"Cannot build with (.+?) because Bun treats literal `\\*` characters in route paths as wildcards\\. Rename the file or route to remove the `\\*` character\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/adapter-bun/index.js","lineNumber":89,"sourceCode":" */\nasync function asset_meta(file, precompress = false) {\n\tconst hash = await hash_file(file);\n\n\t/** @type {{ hash: string, mtime: number, br?: boolean, gz?: boolean }} */\n\tconst meta = { hash, mtime: Bun.file(file).lastModified };\n\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,","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-bun/index.js#L71-L107","documentation":"adapter-bun emits route files into a Bun built-in HTTP router/manifest where a literal '*' in a path is interpreted as a wildcard, conflicting with SvelteKit's rest-route syntax (e.g. [...slug]). The adapter therefore rejects any generated route file path containing '*' at build time.","triggerScenarios":"validate_file_paths was called (from get_embed_entries, get_no_embed_entries, or create_routes) and one of the generated route file paths, e.g. 'src/routes/[...slug]/+page.svelte', contains a '*' character.","commonSituations":"Using SvelteKit rest parameters like [...slug] or catch-all routes with adapter-bun; nested optional rest routes like [[...rest]].","solutions":["Rename the route to avoid '*' — e.g. replace [...slug] with a fixed route or a named param [slug].","Check for accidentally created files/folders with '*' in their name inside src/routes.","Switch to an adapter without this restriction (e.g. adapter-node) if the wildcard route is required."],"exampleFix":"// before\nsrc/routes/[...slug]/+page.svelte\n// after\nsrc/routes/[slug]/+page.svelte  // or handle catch-alls with adapter-node","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\nconst offenders = [];\n(function walk(dir) {\n  for (const f of fs.readdirSync(dir)) {\n    const p = path.join(dir, f);\n    if (fs.statSync(p).isDirectory()) walk(p);\n    else if (p.includes('*')) offenders.push(p);\n  }\n})('src/routes');\nif (offenders.length) throw new Error(`adapter-bun rejects '*' in route paths: ${offenders.join(', ')}`);","typeGuard":"const isBunSafeRoute = (file) => !file.includes('*');","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (/Bun treats literal `\\*` characters in route paths/.test(e.message)) {\n    console.error('Rename the reported route file to remove the * character');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Avoid SvelteKit rest routes ([...slug]) when targeting adapter-bun","Lint src/routes filenames for '*' before builds","Document adapter-bun route naming restrictions in the repo"],"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"}