xai-org/grok-build · error

Failed to load config: {}

Error message

Failed to load config: {}

What it means

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.

Source

Thrown at crates/codegen/xai-grok-pager/src/app/session_startup.rs:1099

        return RemoteMissPlan::RejectInPlaceCodeRestore {
            title_miss_hint: !arg_is_uuid,
        };
    }
    RemoteMissPlan::RestoreConversation
}
/// Remote-restore tail of [`resolve_existing_session`], split out so non-id targets can wrap every failure with the title-miss hint.
///
/// Always restores session state and memory only.
/// Codebase checkout is refused in-place ([`RemoteMissPlan::RejectInPlaceCodeRestore`]) or deferred to the worktree handler.
///
/// 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.
async fn restore_session_from_remote(
    session_id: &str,
    cwd: &str,
    progress_on_stdout: bool,
) -> anyhow::Result<ResolvedExisting> {
    let raw_config = xai_grok_shell::config::load_effective_config()
        .map_err(|e| anyhow::anyhow!("Failed to load config: {}", e))?;
    if let Some((false, source)) =
        xai_grok_shell::util::config::session_registry_local_override_sourced(Some(&raw_config))
    {
        anyhow::bail!(
            "Session does not exist locally (session registry is disabled by {})",
            source.label()
        );
    }
    emit_pre_tui_restore_line(
        progress_on_stdout,
        &format!(
            "Session {:?} not found locally, restoring conversation from remote...",
            session_id
        ),
    );
    let agent_config = xai_grok_shell::agent::config::Config::new_from_toml_cfg(&raw_config)
        .map_err(|e| anyhow::anyhow!("Failed to create agent config: {}", e))?;
    use xai_grok_shell::agent::session_registry_client::SessionRegistryClient;

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Read the inner error after 'Failed to load config:' to find the offending file/field
  2. Fix TOML syntax or schema errors in the config file
  3. Restore read permissions on the config file and its parent directories
  4. Verify env overrides (e.g. config-path env vars) point to a valid file

Example fix

// before: broken TOML from a manual edit
[auth]
api_key = grok-abc  # missing quotes
// after: valid TOML
[auth]
api_key = "grok-abc"
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate the config before a remote restore
let raw = xai_grok_shell::config::load_effective_config();
if raw.is_err() {
    eprintln!("fix config before attempting session restore");
}

Try / catch

match restore_session_from_remote(id, cwd, false).await {
    Err(e) if e.to_string().starts_with("Failed to load config:") => {
        eprintln!("cannot restore: fix config first: {e:#}");
    }
    other => other.map(|_| ()),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/a4e47148161d51bd. Report an issue: GitHub.