{"record":{"id":"61ad61b70fcc19e0","repo":"astrid-runtime/astrid","slug":"mcp-attach-workspace-is-empty","errorCode":null,"errorMessage":"MCP attach workspace is empty","messagePattern":"MCP attach workspace is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/mcp/gateway.rs","lineNumber":972,"sourceCode":"    }\n    Ok(principal)\n}\n\nfn mint_hook_token() -> String {\n    format!(\n        \"{}{}\",\n        Uuid::new_v4().as_simple(),\n        Uuid::new_v4().as_simple()\n    )\n}\n\nfn mint_boot_token() -> String {\n    Uuid::new_v4().as_simple().to_string()\n}\n\nfn validate_workspace(value: &str) -> Result<PathBuf> {\n    if value.is_empty() {\n        anyhow::bail!(\"MCP attach workspace is empty\");\n    }\n    let path = PathBuf::from(value);\n    if !path.is_absolute() {\n        anyhow::bail!(\"MCP attach workspace must be absolute: {value}\");\n    }\n    std::fs::canonicalize(&path)\n        .with_context(|| format!(\"failed to resolve MCP attach workspace {value}\"))\n}\n\nfn set_socket_mode(path: &Path) -> Result<()> {\n    #[cfg(unix)]\n    {\n        use std::os::unix::fs::PermissionsExt;\n        std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))?;\n    }\n    Ok(())\n}\n","sourceCodeStart":954,"sourceCodeEnd":990,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/mcp/gateway.rs#L954-L990","documentation":"validate_workspace converts the workspace string of an attach registration into a canonical PathBuf for the gateway to operate in. An empty string carries no workspace, so it is rejected with this dedicated error before any path handling. The gateway requires an explicit, resolvable workspace directory.","triggerScenarios":"Attach registration's workspace_abs field is an empty string; workspace field lost during serialization or template substitution produced \"\".","commonSituations":"Config with an unset workspace variable interpolated to empty; client forgot to pass the workspace argument; CI environment where WORKSPACE env var is not set.","solutions":["Pass an absolute workspace directory path in the registration","Set the workspace config/env variable before launching the client","Default the workspace to the current directory (canonicalized) if the caller intends cwd","Add a client-side preflight check that the workspace string is non-empty"],"exampleFix":"// before\nworkspace_abs: env::var(\"WORKSPACE\").unwrap_or_default(),\n// after\nworkspace_abs: std::fs::canonicalize(env::var(\"WORKSPACE\").context(\"WORKSPACE must be set\")?)?.display().to_string(),","handlingStrategy":"validation","validationCode":"if workspace.trim().is_empty() { return Err(\"workspace must be a non-empty absolute path\"); }","typeGuard":"fn has_workspace(reg: &AttachRegistration) -> bool { !reg.workspace_abs.is_empty() }","tryCatchPattern":null,"preventionTips":["Require an explicit workspace in config with a startup-time check","Fall back to std::env::current_dir() canonicalized instead of empty","Guard env-var interpolation with defaults"],"tags":["validation","mcp","configuration"],"backgroundTag":"empty-required-field","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}