{"record":{"id":"ed4318fa3cc3fb1a","repo":"xai-org/grok-build","slug":"custom-sandbox-profile-name-not-found-define","errorCode":null,"errorMessage":"Custom sandbox profile '{name}' not found. Define it in ~/.grok/sandbox.toml or .grok/sandbox.toml:\n\n[profiles.{name}]\nextends = \"workspace\"\nread_only = [\"/data\"]\n","messagePattern":"Custom sandbox profile '(.+?)' not found\\. Define it in ~/\\.grok/sandbox\\.toml or \\.grok/sandbox\\.toml:\n\n\\[profiles\\.(.+?)\\]\nextends = \"workspace\"\nread_only = \\[\"/data\"\\]\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-sandbox/src/profiles.rs","lineNumber":477,"sourceCode":"                    read_write: essential_writable_paths(workspace),\n                    deny: vec![],\n                    write_deny: resolve_write_deny(self)?,\n                    default_read: false,\n                    restrict_network: true,\n                })\n            }\n\n            Self::Custom(name) => {\n                let profile_config = config.profiles.get(name).ok_or_else(|| {\n                    anyhow::anyhow!(\n                        \"Custom sandbox profile '{name}' not found. \\\n                         Define it in ~/.grok/sandbox.toml or .grok/sandbox.toml:\\n\\n\\\n                         [profiles.{name}]\\n\\\n                         extends = \\\"workspace\\\"\\n\\\n                         read_only = [\\\"/data\\\"]\\n\"\n                    )\n                })?;\n\n                // Start from the base profile if `extends` is set\n                let (base, mut profile) = if let Some(base_name) = &profile_config.extends {\n                    let base: ProfileName = base_name.parse().map_err(|e: String| {\n                        anyhow::anyhow!(\"Profile '{name}' extends invalid base: {e}\")\n                    })?;\n                    if matches!(base, Self::Off) {\n                        anyhow::bail!(\n                            \"Profile '{name}' extends '{base_name}', but 'off'/'none' \\\n                             is not a valid base profile\"\n                        );\n                    }\n                    if matches!(base, Self::Custom(_)) {\n                        anyhow::bail!(\n                            \"Profile '{name}' extends '{base_name}', but custom profiles \\\n                             cannot extend other custom profiles (only built-ins)\"\n                        );\n                    }\n                    let resolved = base.resolve(workspace, config)?;","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-sandbox/src/profiles.rs#L459-L495","documentation":"`ProfileName::resolve` fails when the sandbox configuration references a custom profile by name that is not defined in either ~/.grok/sandbox.toml (user) or .grok/sandbox.toml (workspace). The error is deliberately verbose and instructive: it names the missing profile and shows the exact TOML snippet needed to define it, typically extending a built-in profile with extra read_only paths.","triggerScenarios":"CLI flag or config sets profile = \"myprofile\" but no [profiles.myprofile] section exists in either config file; the config file exists but in the wrong directory; the section name is misspelled; the file fails to parse so the profile list appears empty.","commonSituations":"Copying a config snippet from docs but forgetting the [profiles.X] header; expecting workspace .grok/sandbox.toml to be picked up when running outside the repo root; typo between profile name in CLI and section name; TOML syntax error silently invalidating the file.","solutions":["Create the profile in ~/.grok/sandbox.toml or .grok/sandbox.toml with the exact section name, e.g. [profiles.<name>] with extends and read_only keys.","Check for typos: the name after `profiles.` must exactly match the name used on the CLI/config reference.","Confirm you are running from the workspace root so .grok/sandbox.toml is discovered, or move the definition to ~/.grok/sandbox.toml.","Validate the TOML file parses (e.g. `tomlcheck` or load it in a quick script) — a parse error can make defined profiles invisible.","If you meant a built-in profile, use its exact name instead of a custom one."],"exampleFix":"# before (.grok/sandbox.toml missing the section)\n# CLI: --profile data-ro  -> not found\n# after\n[profiles.data-ro]\nextends = \"workspace\"\nread_only = [\"/data\"]\n# CLI: --profile data-ro  -> resolves","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn profile_defined(name: &str, workspace: &Path) -> Result<(), String> {\n    let candidates = [workspace.join(\".grok/sandbox.toml\"),\n                      dirs::home_dir().map(|h| h.join(\".grok/sandbox.toml\"))];\n    for f in candidates.into_iter().flatten() {\n        if !f.exists() { continue; }\n        let text = std::fs::read_to_string(&f).map_err(|e| e.to_string())?;\n        let toml: toml::Value = text.parse().map_err(|e| format!(\"{}: {e}\", f.display()))?;\n        if toml.get(\"profiles\").and_then(|p| p.get(name)).is_some() { return Ok(()); }\n    }\n    Err(format!(\"profile '{name}' not found in any sandbox.toml\"))\n}\n// call before resolving the profile","typeGuard":null,"tryCatchPattern":"match resolve_profile(&name, workspace) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"not found. Define it in\") => {\n        eprintln!(\"{e:#}\"); // the error already contains the exact TOML snippet to add\n        eprintln!(\"Or check you are running from the workspace root so .grok/sandbox.toml is found.\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Define every custom profile referenced by CLIs/scripts in ~/.grok/sandbox.toml for portability.","Keep profile section names exactly matching the names used on the command line.","Validate sandbox.toml parses at startup (a TOML error hides defined profiles).","Run from the workspace root (or set an explicit config path) so .grok/sandbox.toml is discovered.","Copy the [profiles.X] template from the error message — it shows the minimal valid definition."],"tags":["rust","sandbox","configuration","toml","profile"],"backgroundTag":"profile-not-found","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}