diegosouzapw/OmniRoute · error · Error
GROK_HOME must be an absolute path without traversal
Error message
GROK_HOME must be an absolute path without traversal
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/shared/services/grokBuildConfig.ts:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/84e897f5c2abf177.
Report an issue: GitHub.
Appendix: source
Thrown at src/shared/services/grokBuildConfig.ts:40
subagentModels: Record<GrokSubagentType, GrokModelConfig | null>;
subagentMappings: Record<GrokSubagentType, string | null>;
}
export interface GrokBuildApplyOptions {
baseUrl: string;
apiKey?: string | null;
model: string;
contextWindow?: number;
subagentModels?: Partial<Record<GrokSubagentType, { model: string; contextWindow?: number }>>;
}
/** Resolve config.toml from GROK_HOME or the CLI config home. */
export function resolveGrokBuildConfigPath(env: NodeJS.ProcessEnv, configHome: string): string {
const grokHome = env.GROK_HOME?.trim();
if (!grokHome) return path.join(configHome, ".grok", "config.toml");
const hasTraversal = grokHome.split(/[\\/]+/).includes("..");
if (!path.isAbsolute(grokHome) || hasTraversal) {
throw new Error("GROK_HOME must be an absolute path without traversal");
}
if (/[$`;&|<>\r\n\0]/.test(grokHome)) {
throw new Error("GROK_HOME contains invalid characters");
}
return path.join(path.normalize(grokHome), "config.toml");
}
const UNSET_SENTINEL = "__omniroute_unset__";
const MANAGED_MARKER = '# omniroute-managed = "true"';
const LEGACY_DESCRIPTION = "Routed via OmniRoute gateway";
const MODELS_SECTION = "models";
const SUBAGENT_MODELS_SECTION = "subagents.models";
const escapeRegExp = (value: string): string => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const tomlString = (value: string): string => JSON.stringify(String(value));
const modelSlot = (type: GrokSubagentType): string => `${GROK_MAIN_MODEL_SLOT}-${type}`;
const sectionRegExp = (section: string): RegExp =>View on GitHub (pinned to a179ffed5b)