{"record":{"id":"a7de0799bc1f20cf","repo":"xai-org/grok-build","slug":"invalid-grok-chat-local-workspace-mode-env-othe","errorCode":null,"errorMessage":"invalid {GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV}={other:?}; expected own|attach","messagePattern":"invalid (.+?)=(.+?); expected own\\|attach","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/session_startup.rs","lineNumber":441,"sourceCode":"    let cli_attach = cli_attach.map(str::trim).filter(|s| !s.is_empty());\n    let cli_requested = cli_own.is_some() || cli_attach.is_some();\n    let env_requested = env_enable || env_mode.is_some() || env_server_id.is_some();\n    if !cli_requested && !env_requested {\n        return Ok(None);\n    }\n    if !chat {\n        anyhow::bail!(\"{LOCAL_WORKSPACE_REQUIRES_CHAT}\");\n    }\n    let mode = if cli_attach.is_some() {\n        LocalWorkspaceMode::Attach\n    } else if cli_own.is_some() {\n        LocalWorkspaceMode::Own\n    } else if let Some(ref m) = env_mode {\n        match m.as_str() {\n            \"attach\" => LocalWorkspaceMode::Attach,\n            \"own\" => LocalWorkspaceMode::Own,\n            other => {\n                anyhow::bail!(\n                    \"invalid {GROK_CHAT_LOCAL_WORKSPACE_MODE_ENV}={other:?}; expected own|attach\"\n                )\n            }\n        }\n    } else if env_server_id.is_some() {\n        LocalWorkspaceMode::Attach\n    } else {\n        LocalWorkspaceMode::Own\n    };\n    let cwd = cli_cwd\n        .map(std::path::Path::to_path_buf)\n        .or_else(|| cli_own.and_then(|inner| inner.map(std::path::Path::to_path_buf)))\n        .or(env_cwd)\n        .unwrap_or_else(|| {\n            std::env::current_dir().unwrap_or_else(|_| std::path::PathBuf::from(\".\"))\n        });\n    let cwd = if cwd.is_absolute() {\n        cwd","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/session_startup.rs#L423-L459","documentation":"The env var `GROK_CHAT_LOCAL_WORKSPACE_MODE` must be exactly `own` or `attach`. Any other non-empty value causes `resolve_local_workspace_config` to bail with `invalid GROK_CHAT_LOCAL_WORKSPACE_MODE=<value>; expected own|attach` (session_startup.rs:441).","triggerScenarios":"Setting GROK_CHAT_LOCAL_WORKSPACE_MODE to a typo, different casing (e.g. `Own`, `ATTACH`), or an unsupported value like `shared` while any local-workspace request is active.","commonSituations":"Copy-pasted config from docs of another tool; shell profile exports with wrong casing; YAML/JSON values pasted with surrounding characters.","solutions":["Set the env var to exactly `own` or `attach` (lowercase, no whitespace)","Unset GROK_CHAT_LOCAL_WORKSPACE_MODE and rely on CLI flags instead","Check the value for typos/case with `echo $GROK_CHAT_LOCAL_WORKSPACE_MODE`"],"exampleFix":"// before\nexport GROK_CHAT_LOCAL_WORKSPACE_MODE=Own\n// after\nexport GROK_CHAT_LOCAL_WORKSPACE_MODE=own","handlingStrategy":"validation","validationCode":"fn valid_ws_mode() -> Result<(), String> {\n    match std::env::var(\"GROK_CHAT_LOCAL_WORKSPACE_MODE\") {\n        Ok(m) if matches!(m.trim(), \"own\" | \"attach\") => Ok(()),\n        Ok(m) => Err(format!(\"invalid GROK_CHAT_LOCAL_WORKSPACE_MODE={m:?}; expected own|attach\")),\n        Err(_) => Ok(()),\n    }\n}","typeGuard":"fn is_valid_mode(m: &str) -> bool { matches!(m, \"own\" | \"attach\") }","tryCatchPattern":"match resolve_local_workspace_config(chat, own, attach, cwd) {\n    Err(e) if e.to_string().contains(\"expected own|attach\") => {\n        eprintln!(\"fix GROK_CHAT_LOCAL_WORKSPACE_MODE to 'own' or 'attach': {e}\")\n    }\n    other => other?,\n}","preventionTips":["Use lowercase 'own'/'attach' only","Quote env values in shell profiles to avoid stray characters","Validate env vars in entrypoint scripts before launching the tool"],"tags":["env","validation","local-workspace"],"backgroundTag":"invalid-env-var-value","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}