{"record":{"id":"df768154ab7215d2","repo":"JuliusBrussee/caveman","slug":"name-contains-an-invalid-path-character","errorCode":null,"errorMessage":"${name} contains an invalid path character","messagePattern":"(.+?) contains an invalid path character","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":10757,"sourceCode":"  if (!(keyPath[keyPath.length - 1]! in cur)) return true;\n  delete cur[keyPath[keyPath.length - 1]!];\n  try {\n    writeFileSync(path, JSON.stringify(root, null, 2) + \"\\n\");\n    return true;\n  } catch (e) {\n    console.error(`${mark(\"warn\")} cannot write ${path}: ${(e as Error).message}`);\n    return false;\n  }\n}\n\ntype KiloConfigLocation = {\n  path: string;\n  jsonc: boolean;\n  source: \"KILO_CONFIG_DIR\" | \"KILO_CONFIG\" | \"XDG_CONFIG_HOME\";\n};\n\nfunction kiloPathFromEnv(value: string, name: string): string {\n  if (/[\\0\\r\\n]/.test(value)) throw new Error(`${name} contains an invalid path character`);\n  // Kilo passes env paths directly to its loader. Shell-style \"~/\" expansion\n  // does not occur inside an environment value; relative paths resolve from cwd.\n  return normalize(isAbsolute(value) ? value : resolve(value));\n}\n\nfunction kiloConfigInDirectory(directory: string, source: KiloConfigLocation[\"source\"]): KiloConfigLocation {\n  // Mirror pinned Kilo's native global writer: prefer an existing canonical\n  // config in this order, otherwise create kilo.json. JSONC stays read-only here\n  // because a JSON stringify would destroy comments.\n  const candidates = [\"kilo.jsonc\", \"kilo.json\", \"opencode.jsonc\", \"opencode.json\"];\n  const selected = candidates.map((name) => join(directory, name)).find((path) => existsSync(path))\n    ?? join(directory, \"kilo.json\");\n  return { path: selected, jsonc: extname(selected).toLowerCase() === \".jsonc\", source };\n}\n\n// Kilo 7.5.6's native config writer targets KILO_CONFIG_DIR when present. That\n// directory is also loaded after KILO_CONFIG, so it must win for effective MCP\n// ownership. Explicit KILO_CONFIG wins only without a custom config directory;","sourceCodeStart":10739,"sourceCodeEnd":10775,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/5184b3d11ac6a1acb7d44b9bfaa31698157cff97/packages/cli/src/index.ts#L10739-L10775","documentation":"Validation of a Kilo-related environment variable (e.g. KILO_CONFIG_DIR or KILO_CONFIG): its value contains a NUL, carriage return, or newline character. Such bytes cannot appear in a valid filesystem path, so kiloPathFromEnv rejects the variable before it is used to locate config files.","triggerScenarios":"Thrown at packages/cli/src/index.ts:10757 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip stray control characters (NUL, CR, LF) from the named environment variable in your shell or .env source","Check for quoting mistakes like embedded line breaks when exporting the variable","Unset the variable to let Kilo fall back to its default config location"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5184b3d11ac6a1acb7d44b9bfaa31698157cff97","analyzedAt":"2026-09-06T12:00:26.372Z","contentChangedAt":"2026-09-06T12:00:26.372Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}