{"record":{"id":"d469f73f60392754","repo":"astrid-runtime/astrid","slug":"mcp-attach-workspace-must-be-an-absolute-path","errorCode":null,"errorMessage":"MCP attach workspace must be an absolute path: {}","messagePattern":"MCP attach workspace must be an absolute path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/mcp/attach.rs","lineNumber":75,"sourceCode":"    stream\n        .write_all(b\"\\n\")\n        .await\n        .context(\"failed to terminate MCP attach registration\")?;\n    stream\n        .flush()\n        .await\n        .context(\"failed to flush MCP attach registration\")?;\n    proxy_stdio(stream).await?;\n    Ok(ExitCode::SUCCESS)\n}\n\nfn absolute_workspace(workspace: Option<&Path>) -> Result<PathBuf> {\n    let path = workspace.map_or(\n        std::env::current_dir().context(\"failed to read MCP attach cwd\")?,\n        PathBuf::from,\n    );\n    if !path.is_absolute() {\n        anyhow::bail!(\n            \"MCP attach workspace must be an absolute path: {}\",\n            path.display()\n        );\n    }\n    std::fs::canonicalize(&path)\n        .with_context(|| format!(\"failed to resolve MCP attach workspace {}\", path.display()))\n}\n\nfn build_registration(\n    caller: &astrid_core::PrincipalId,\n    workspace: Option<&Path>,\n    ready: &super::lifecycle::GatewayReady,\n) -> Result<AttachRegistration> {\n    let host = std::env::var(\"ASTRID_HOST\")\n        .or_else(|_| std::env::var(\"AOS_MCP_HOST\"))\n        .or_else(|_| std::env::var(\"MCP_HOST\"))\n        .ok()\n        .filter(|value| !value.trim().is_empty())","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/mcp/attach.rs#L57-L93","documentation":"absolute_workspace normalizes the workspace path for the attach registration and requires it to be absolute before canonicalizing. A relative workspace argument (or an unset one whose current_dir lookup can't apply) is rejected so the daemon receives an unambiguous path.","triggerScenarios":"Passing a relative path (e.g. \".\" or \"./ws\") to `aos mcp attach --workspace` and the path failing path.is_absolute().","commonSituations":"Invoking the CLI from scripts with a relative directory; shell cwd differing from expectation; forgetting to convert a configured relative workspace to an absolute path.","solutions":["Pass an absolute path: `aos mcp attach --workspace /home/me/project`","Prefix the path with $(pwd) in scripts","Check for a typo such as a missing leading '/' or '~' not expanded by the program"],"exampleFix":"// before\n$ aos mcp attach --workspace ./myproject\n// after\n$ aos mcp attach --workspace \"$(pwd)/myproject\"","handlingStrategy":"validation","validationCode":"let ws = workspace.unwrap_or_else(|| std::env::current_dir().unwrap());\nassert!(ws.is_absolute(), \"workspace must be absolute: {}\", ws.display());","typeGuard":"fn is_absolute_ws(p: &Path) -> bool { p.is_absolute() }","tryCatchPattern":"match absolute_workspace(Some(&ws)) {\n    Err(e) if e.to_string().contains(\"absolute path\") => eprintln!(\"pass an absolute --workspace\"),\n    other => other,\n}","preventionTips":["Always pass absolute paths to --workspace","Use \"$(pwd)\" prefix in scripts","Expand '~' before invoking the CLI"],"tags":["mcp","path-validation","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}