{"record":{"id":"84e897f5c2abf177","repo":"diegosouzapw/OmniRoute","slug":"grok-home-must-be-an-absolute-path-without-travers","errorCode":null,"errorMessage":"GROK_HOME must be an absolute path without traversal","messagePattern":"GROK_HOME must be an absolute path without traversal","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/services/grokBuildConfig.ts","lineNumber":40,"sourceCode":"  subagentModels: Record<GrokSubagentType, GrokModelConfig | null>;\n  subagentMappings: Record<GrokSubagentType, string | null>;\n}\n\nexport interface GrokBuildApplyOptions {\n  baseUrl: string;\n  apiKey?: string | null;\n  model: string;\n  contextWindow?: number;\n  subagentModels?: Partial<Record<GrokSubagentType, { model: string; contextWindow?: number }>>;\n}\n\n/** Resolve config.toml from GROK_HOME or the CLI config home. */\nexport function resolveGrokBuildConfigPath(env: NodeJS.ProcessEnv, configHome: string): string {\n  const grokHome = env.GROK_HOME?.trim();\n  if (!grokHome) return path.join(configHome, \".grok\", \"config.toml\");\n  const hasTraversal = grokHome.split(/[\\\\/]+/).includes(\"..\");\n  if (!path.isAbsolute(grokHome) || hasTraversal) {\n    throw new Error(\"GROK_HOME must be an absolute path without traversal\");\n  }\n  if (/[$`;&|<>\\r\\n\\0]/.test(grokHome)) {\n    throw new Error(\"GROK_HOME contains invalid characters\");\n  }\n  return path.join(path.normalize(grokHome), \"config.toml\");\n}\n\nconst UNSET_SENTINEL = \"__omniroute_unset__\";\nconst MANAGED_MARKER = '# omniroute-managed = \"true\"';\nconst LEGACY_DESCRIPTION = \"Routed via OmniRoute gateway\";\nconst MODELS_SECTION = \"models\";\nconst SUBAGENT_MODELS_SECTION = \"subagents.models\";\n\nconst escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\nconst tomlString = (value: string): string => JSON.stringify(String(value));\nconst modelSlot = (type: GrokSubagentType): string => `${GROK_MAIN_MODEL_SLOT}-${type}`;\n\nconst sectionRegExp = (section: string): RegExp =>","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/shared/services/grokBuildConfig.ts#L22-L58","documentation":"Configuration validation error while resolving the Grok CLI config.toml path: the GROK_HOME env var was set to a relative path or contained `..` traversal segments. Only absolute, traversal-free directories are accepted to keep config writes anchored.","triggerScenarios":"Thrown at src/shared/services/grokBuildConfig.ts:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set GROK_HOME to an absolute path (e.g. /home/user/.grok)","Remove any `..` segments from GROK_HOME","Unset GROK_HOME to fall back to the default CLI config home","Resolve the path to an absolute form before exporting the env var"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}