{"record":{"id":"a4e47148161d51bd","repo":"xai-org/grok-build","slug":"failed-to-load-config-a4e471","errorCode":null,"errorMessage":"Failed to load config: {}","messagePattern":"Failed to load config: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/session_startup.rs","lineNumber":1099,"sourceCode":"        return RemoteMissPlan::RejectInPlaceCodeRestore {\n            title_miss_hint: !arg_is_uuid,\n        };\n    }\n    RemoteMissPlan::RestoreConversation\n}\n/// Remote-restore tail of [`resolve_existing_session`], split out so non-id targets can wrap every failure with the title-miss hint.\n///\n/// Always restores session state and memory only.\n/// Codebase checkout is refused in-place ([`RemoteMissPlan::RejectInPlaceCodeRestore`]) or deferred to the worktree handler.\n///\n/// On timeout the future is cancelled; partial JSONL may already be on disk and is recovered via a local-child scan of the remote id.\nasync fn restore_session_from_remote(\n    session_id: &str,\n    cwd: &str,\n    progress_on_stdout: bool,\n) -> anyhow::Result<ResolvedExisting> {\n    let raw_config = xai_grok_shell::config::load_effective_config()\n        .map_err(|e| anyhow::anyhow!(\"Failed to load config: {}\", e))?;\n    if let Some((false, source)) =\n        xai_grok_shell::util::config::session_registry_local_override_sourced(Some(&raw_config))\n    {\n        anyhow::bail!(\n            \"Session does not exist locally (session registry is disabled by {})\",\n            source.label()\n        );\n    }\n    emit_pre_tui_restore_line(\n        progress_on_stdout,\n        &format!(\n            \"Session {:?} not found locally, restoring conversation from remote...\",\n            session_id\n        ),\n    );\n    let agent_config = xai_grok_shell::agent::config::Config::new_from_toml_cfg(&raw_config)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create agent config: {}\", e))?;\n    use xai_grok_shell::agent::session_registry_client::SessionRegistryClient;","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/session_startup.rs#L1081-L1117","documentation":"restore_session_from_remote needs the effective config to decide whether the local session registry is overridden and to drive the remote restore. If load_effective_config() fails, the error is wrapped as 'Failed to load config' and the remote restore aborts.","triggerScenarios":"Calling the resume path (materialize/restore by id) while load_effective_config() fails: malformed/unreadable config TOML, bad env overrides, or missing config directory — same root causes as other config-load errors.","commonSituations":"Resuming a session after a config edit introduced invalid TOML; config file permissions changed (e.g. after switching users or sudo); XDG config env var pointing at a nonexistent location.","solutions":["Read the inner error after 'Failed to load config:' to find the offending file/field","Fix TOML syntax or schema errors in the config file","Restore read permissions on the config file and its parent directories","Verify env overrides (e.g. config-path env vars) point to a valid file"],"exampleFix":"// before: broken TOML from a manual edit\n[auth]\napi_key = grok-abc  # missing quotes\n// after: valid TOML\n[auth]\napi_key = \"grok-abc\"","handlingStrategy":"validation","validationCode":"// pre-validate the config before a remote restore\nlet raw = xai_grok_shell::config::load_effective_config();\nif raw.is_err() {\n    eprintln!(\"fix config before attempting session restore\");\n}","typeGuard":null,"tryCatchPattern":"match restore_session_from_remote(id, cwd, false).await {\n    Err(e) if e.to_string().starts_with(\"Failed to load config:\") => {\n        eprintln!(\"cannot restore: fix config first: {e:#}\");\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["Validate the config file (TOML parse) before resume workflows","Keep config permissions consistent (readable by the running user)","Avoid env-var overrides pointing at missing config paths","Load the config once early and surface failures before any remote calls"],"tags":["config","session","resume","startup"],"backgroundTag":"config-load-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}