Hmbown/CodeWhale · error
Expected Ok for scoped npm package via
Error message
Expected Ok for scoped npm package via {command}, got {other:?} What it means
This is a test-only panic in the MCP server doctor tests of the TUI crate. The test starts an MCP server defined as a scoped npm package (@playwright/mcp@0.0.79) invoked via a package-runner command (npx/bunx) and expects doctor_check_mcp_server to return McpServerDoctorStatus::Ok with a detail mentioning "stdio". Any other variant (Warning or Error) means the doctor incorrectly classified a valid scoped-npm stdio server.
Solutions
- Run the failing test and inspect the {other:?} variant in the panic message to see whether the doctor returned Warning or Error and what detail it produced.
- Check doctor_check_mcp_server's command classification for scoped npm packages (@scope/name) and restore the stdio detection / Ok classification.
- If the doctor is now intentionally stricter, update the test expectation to the new documented behavior.
Example fix
// before
other => panic!("Expected Ok for scoped npm package via {command}, got {other:?}"),
// after (diagnostic step)
other => panic!("Expected Ok for scoped npm package via {command}, got {other:?}; doctor classification for @scope/pkg commands changed"), Defensive patterns
Strategy: validation
Validate before calling
// before relying on the doctor, assert the classification yourself
assert!(Path::new(command).is_absolute() || command.ends_with(".js") || is_scoped_npm(command), "unexpected command shape: {command}"); Type guard
fn is_ok_status(s: &McpServerDoctorStatus) -> bool { matches!(s, McpServerDoctorStatus::Ok(_)) } Try / catch
match doctor_check_mcp_server(&server) { McpServerDoctorStatus::Ok(d) => d, other => panic!("doctor classified scoped npm server as {other:?}") } Prevention
- Cover scoped npm (@scope/pkg) commands explicitly in doctor unit tests
- Keep classification logic (absolute/relative/npm) in one pure function that is easy to table-test
When it happens
Trigger: Running the TUI test that calls doctor_check_mcp_server on an McpServerConfig with a scoped npm package command and args ["-y","@playwright/mcp@0.0.79","--isolated"], when the doctor logic returns Warning or Error instead of Ok — e.g. the scoped-package detection in the doctor regressed or the detail text no longer contains "stdio".
Common situations: A developer modified doctor_check_mcp_server's command/path classification (npm/npx/bunx scoped-package handling, relative-path warnings) and broke the special-case for @scope/package names; or renamed McpServerDoctorStatus variants/messages.
Related errors
- Expected Ok when cwd anchors relative path, got
- Absolute path should not warn
- connection stdin poisoned by an earlier panic
- Expected Ok, got
- Expected Warning for relative path argument, got
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/6e2ddc6ab097c0e2.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:19421
}
}
#[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")),
other => panic!("Expected Ok for scoped npm package via {command}, got {other:?}"),
}
}
}
#[test]
fn test_scoped_npm_exception_does_not_hide_relative_paths() {
for (command, argument) in [
("npx", "scripts/server.js"),
("npx", "@scope/package/extra"),
("npx", "@scope/package@"),
("npx", "@scope/package@@1.0.0"),
("npx", "@.scope/package"),
("npx.cmd", "@scope/_package"),
("node", "@scope/package@1.0.0"),
] {
let server = make_server(Some(command), &[argument], None);
assert!(
matches!(View on GitHub (pinned to 433685b202)