xai-org/grok-build · error

{LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID}

Error message

{LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID}

What it means

In Attach mode the server id must come from the CLI (`--local-workspace-attach <id>`) or the env `GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID`, and it must be non-empty. When both are missing/empty, `resolve_local_workspace_config` bails with `LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID` (session_startup.rs:478).

Source

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

    } else {
        std::env::current_dir()
            .unwrap_or_else(|_| std::path::PathBuf::from("."))
            .join(cwd)
    };
    let cwd = validate_local_workspace_cwd(&cwd)?;
    match mode {
        LocalWorkspaceMode::Own => Ok(Some(LocalWorkspaceConfig {
            mode,
            cwd: Some(cwd),
            server_id: None,
        })),
        LocalWorkspaceMode::Attach => {
            let server_id = cli_attach
                .map(str::to_owned)
                .or(env_server_id)
                .filter(|s| !s.is_empty());
            let Some(server_id) = server_id else {
                anyhow::bail!("{LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID}");
            };
            ensure_attach_fs_only_toolset(&server_id)?;
            Ok(Some(LocalWorkspaceConfig {
                mode,
                cwd: Some(cwd),
                server_id: Some(server_id),
            }))
        }
    }
}
/// Canonicalize `path` and enforce the `/` and `$HOME` denylist.
///
/// Returns the canonical directory so callers stamp and persist what was actually checked (symlinks and `..` must not diverge from validation).
#[cfg(feature = "local-workspace")]
pub fn validate_local_workspace_cwd(path: &std::path::Path) -> anyhow::Result<std::path::PathBuf> {
    let abs = if path.is_absolute() {
        path.to_path_buf()
    } else {

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Pass the server id: `--local-workspace-attach <server-id>`
  2. Set GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID to a non-empty id
  3. Verify the script variable holding the id is not empty before invoking

Example fix

// before
export GROK_CHAT_LOCAL_WORKSPACE_MODE=attach
# (no server id)
// after
export GROK_CHAT_LOCAL_WORKSPACE_MODE=attach
export GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID=my-server
Defensive patterns

Strategy: validation

Validate before calling

fn attach_server_id(cli_attach: Option<&str>) -> Result<String, String> {
    let id = cli_attach.map(str::trim).filter(|s| !s.is_empty())
        .or_else(|| std::env::var("GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID").ok().map(|s| s.trim().to_string()).filter(|s| !s.is_empty()));
    id.ok_or_else(|| "attach mode requires --local-workspace-attach <id> or GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID".into())
}

Try / catch

match resolve_local_workspace_config(chat, own, attach, cwd) {
    Err(e) if e.to_string().contains("SERVER_ID") || e.to_string().contains("ATTACH_NEEDS_SERVER_ID") => {
        eprintln!("attach mode needs a non-empty server id: {e}")
    }
    other => other?,
}

Prevention

When it happens

Trigger: Attaching via env (`GROK_CHAT_LOCAL_WORKSPACE_MODE=attach` or server-id-only env) without a server id; passing an empty/whitespace `--local-workspace-attach ""`; server id supplied only via env but that var unset.

Common situations: Setting mode=attach but forgetting GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID; the attach flag passed with an empty argument by a script variable that expanded to nothing.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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