Hmbown/CodeWhale · error
Expected Warning for relative path argument, got
Error message
Expected Warning for relative path argument, got {other:?} What it means
A test assertion panic in the MCP doctor tests: the test expects doctor_check_mcp_server to return McpServerDoctorStatus::Warning with a detail mentioning both 'relative path argument' and 'cwd' when a stdio server's argument is the relative path 'server/mcp_server.py' and no cwd is set. Any other variant panics with 'Expected Warning for relative path argument, got {other:?}'.
Solutions
- Print the actual variant in the panic ({other:?}) to see what the doctor decided.
- Extend the relative-path detection in doctor_check_mcp_server to catch multi-segment relative args like 'server/mcp_server.py'.
- Verify the Warning detail still contains both 'relative path argument' and 'cwd', or update the assertions.
- Add/confirm a sibling test (scoped npm spec is NOT a warning) still passes so the heuristic stays precise.
Example fix
// before
other => panic!("Expected Warning for relative path argument, got {other:?}"),
// after
other => panic!("Expected Warning for relative path argument, got {other:?}; server={server:?}"), Defensive patterns
Strategy: validation
Validate before calling
fn looks_like_relative_path(arg: &str) -> bool {
!arg.starts_with('/') && !arg.starts_with("@") && arg.contains('.')
}
if !server.args.iter().any(|a| looks_like_relative_path(a)) {
eprintln!("no relative path arg; doctor will not warn");
} Type guard
fn is_relative_path_arg(s: &str) -> bool {
!std::path::Path::new(s).is_absolute() && !s.starts_with('@')
} Try / catch
match doctor_check_mcp_server(&server) {
McpServerDoctorStatus::Warning(d) => {
assert!(d.contains("relative path argument"), "{d}");
assert!(d.contains("cwd"), "{d}");
}
other => panic!("Expected Warning for relative path argument, got {other:?}"),
} Prevention
- Match relative paths by non-absolute prefix, not by file extension or depth
- Keep warning copy keywords ('relative path argument', 'cwd') stable
- Pair each positive case with a negative case (scoped npm specs)
- Log the full variant in panics for faster triage
When it happens
Trigger: doctor_check_mcp_server returns Ok or Error instead of the expected Warning — e.g. the relative-path heuristic was removed, now matches only single-segment paths (missing the 'server/' prefix case), or raises a hard error instead of a warning.
Common situations: A doctor change tightens path matching to file extensions or single components and misses nested relative paths; wording changed from 'relative path argument'/'cwd'; the check was demoted to Ok.
Related errors
- Expected Ok, got
- connection stdin poisoned by an earlier panic
- Expected Ok for scoped npm package via
- Expected Ok when cwd anchors relative path, got
- expected resume command
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/8a311d1be440f6e0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:19402
let executable = executable.to_string_lossy();
let server = make_server(Some(&executable), &["server.js"], None);
match doctor_check_mcp_server(&server) {
McpServerDoctorStatus::Ok(detail) => assert!(detail.contains("stdio")),
other => panic!("Expected Ok, got {other:?}"),
}
}
#[test]
fn test_relative_stdio_path_arg_without_cwd_warns() {
let executable = std::env::current_exe().expect("current test executable");
let executable = executable.to_string_lossy();
let server = make_server(Some(&executable), &["server/mcp_server.py"], None);
match doctor_check_mcp_server(&server) {
McpServerDoctorStatus::Warning(detail) => {
assert!(detail.contains("relative path argument"));
assert!(detail.contains("cwd"));
}
other => panic!("Expected Warning for relative path argument, got {other:?}"),
}
}
#[test]
fn test_scoped_npm_package_spec_without_cwd_is_not_a_path_warning() {
let absolute_npx = if cfg!(windows) {
r"C:\Program Files\nodejs\npx.cmd"
} else {
"/opt/homebrew/bin/npx"
};
for command in ["npx", "npx.cmd", absolute_npx] {
let server = make_server(
Some(command),
&["-y", "@playwright/mcp@0.0.79", "--isolated"],
None,
);
match doctor_check_mcp_server(&server) {
McpServerDoctorStatus::Ok(detail) => assert!(detail.contains("stdio")),View on GitHub (pinned to 433685b202)