Hmbown/CodeWhale · error · anyhow::Error

MCP config path cannot be empty

Error message

MCP config path cannot be empty

What it means

validate_mcp_config_path rejected a config path whose OS string is empty. This guard runs on every load/save of the MCP config and exists to stop an empty path from being joined and written somewhere unintended.

Source

Thrown at crates/tui/src/mcp.rs:48

mod wire;

use self::http::{HttpTransport, McpHttpAuth};
use self::sse::SseTransport;
use self::stdio::StdioTransport;
#[cfg(all(test, unix))]
use self::stdio::{STDIO_SHUTDOWN_GRACE, StderrTail};
use self::wire::{is_mcp_stale_session_body, is_mcp_stale_session_error};
use crate::network_policy::{Decision, NetworkPolicyDecider, host_from_url};
use crate::utils::write_atomic;

// === Error diagnostics helpers (#71) ===

/// Bytes of a non-2xx response body to surface in connection errors.
const ERROR_BODY_PREVIEW_BYTES: usize = 200;

fn validate_mcp_config_path(path: &Path) -> Result<()> {
    if path.as_os_str().is_empty() {
        anyhow::bail!("MCP config path cannot be empty");
    }
    if path
        .components()
        .any(|component| matches!(component, Component::ParentDir))
    {
        anyhow::bail!("MCP config path cannot contain '..' components");
    }
    Ok(())
}

/// Expand `${NAME}` placeholders in an MCP config value from the process
/// environment. This lets secrets (API keys, bearer tokens, …) be supplied
/// through environment variables instead of being written in cleartext into
/// the MCP config file on disk.
///
/// On a missing or malformed placeholder the error names only the offending
/// variable, never the surrounding value, so a secret-bearing string is never
/// echoed into logs or error output.

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Supply the explicit --config path
  2. Or run from a workspace so the default config path resolves
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/mcp.rs:48 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/c48ccdd89f94e732. Report an issue: GitHub.