{"record":{"id":"ccc67eb4f113c83e","repo":"xai-org/grok-build","slug":"local-workspace-attach-needs-server-id","errorCode":null,"errorMessage":"{LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID}","messagePattern":"\\{LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/session_startup.rs","lineNumber":478,"sourceCode":"    } else {\n        std::env::current_dir()\n            .unwrap_or_else(|_| std::path::PathBuf::from(\".\"))\n            .join(cwd)\n    };\n    let cwd = validate_local_workspace_cwd(&cwd)?;\n    match mode {\n        LocalWorkspaceMode::Own => Ok(Some(LocalWorkspaceConfig {\n            mode,\n            cwd: Some(cwd),\n            server_id: None,\n        })),\n        LocalWorkspaceMode::Attach => {\n            let server_id = cli_attach\n                .map(str::to_owned)\n                .or(env_server_id)\n                .filter(|s| !s.is_empty());\n            let Some(server_id) = server_id else {\n                anyhow::bail!(\"{LOCAL_WORKSPACE_ATTACH_NEEDS_SERVER_ID}\");\n            };\n            ensure_attach_fs_only_toolset(&server_id)?;\n            Ok(Some(LocalWorkspaceConfig {\n                mode,\n                cwd: Some(cwd),\n                server_id: Some(server_id),\n            }))\n        }\n    }\n}\n/// Canonicalize `path` and enforce the `/` and `$HOME` denylist.\n///\n/// Returns the canonical directory so callers stamp and persist what was actually checked (symlinks and `..` must not diverge from validation).\n#[cfg(feature = \"local-workspace\")]\npub fn validate_local_workspace_cwd(path: &std::path::Path) -> anyhow::Result<std::path::PathBuf> {\n    let abs = if path.is_absolute() {\n        path.to_path_buf()\n    } else {","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/session_startup.rs#L460-L496","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the server id: `--local-workspace-attach <server-id>`","Set GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID to a non-empty id","Verify the script variable holding the id is not empty before invoking"],"exampleFix":"// before\nexport GROK_CHAT_LOCAL_WORKSPACE_MODE=attach\n# (no server id)\n// after\nexport GROK_CHAT_LOCAL_WORKSPACE_MODE=attach\nexport GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID=my-server","handlingStrategy":"validation","validationCode":"fn attach_server_id(cli_attach: Option<&str>) -> Result<String, String> {\n    let id = cli_attach.map(str::trim).filter(|s| !s.is_empty())\n        .or_else(|| std::env::var(\"GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID\").ok().map(|s| s.trim().to_string()).filter(|s| !s.is_empty()));\n    id.ok_or_else(|| \"attach mode requires --local-workspace-attach <id> or GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID\".into())\n}","typeGuard":null,"tryCatchPattern":"match resolve_local_workspace_config(chat, own, attach, cwd) {\n    Err(e) if e.to_string().contains(\"SERVER_ID\") || e.to_string().contains(\"ATTACH_NEEDS_SERVER_ID\") => {\n        eprintln!(\"attach mode needs a non-empty server id: {e}\")\n    }\n    other => other?,\n}","preventionTips":["Always set GROK_CHAT_LOCAL_WORKSPACE_SERVER_ID when mode=attach","Check script variables for emptiness before passing --local-workspace-attach \"$ID\"","Prefer the explicit CLI flag over env in automation"],"tags":["local-workspace","missing-argument","env"],"backgroundTag":"missing-required-parameter","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}