astrid-runtime/astrid · error
MCP attach workspace is empty
Error message
MCP attach workspace is empty
What it means
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.
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
Example fix
// before
workspace_abs: env::var("WORKSPACE").unwrap_or_default(),
// after
workspace_abs: std::fs::canonicalize(env::var("WORKSPACE").context("WORKSPACE must be set")?)?.display().to_string(), Defensive patterns
Strategy: validation
Validate before calling
if workspace.trim().is_empty() { return Err("workspace must be a non-empty absolute path"); } Type guard
fn has_workspace(reg: &AttachRegistration) -> bool { !reg.workspace_abs.is_empty() } Prevention
- 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
When it happens
Trigger: Attach registration's workspace_abs field is an empty string; workspace field lost during serialization or template substitution produced "".
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- capsule ' ': distro capsules require a concrete released…
- distro must have at least one capsule with role = "uplink"…
- invites.issuers is non-empty but invites.default-group is…
- invites.max-principals must be "unlimited" or a…
- MCP attach host is empty
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/61ad61b70fcc19e0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/astrid-cli/src/commands/mcp/gateway.rs:972
}
Ok(principal)
}
fn mint_hook_token() -> String {
format!(
"{}{}",
Uuid::new_v4().as_simple(),
Uuid::new_v4().as_simple()
)
}
fn mint_boot_token() -> String {
Uuid::new_v4().as_simple().to_string()
}
fn validate_workspace(value: &str) -> Result<PathBuf> {
if value.is_empty() {
anyhow::bail!("MCP attach workspace is empty");
}
let path = PathBuf::from(value);
if !path.is_absolute() {
anyhow::bail!("MCP attach workspace must be absolute: {value}");
}
std::fs::canonicalize(&path)
.with_context(|| format!("failed to resolve MCP attach workspace {value}"))
}
fn set_socket_mode(path: &Path) -> Result<()> {
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))?;
}
Ok(())
}
View on GitHub (pinned to affd8760f4)