Hmbown/CodeWhale · error

Expected Ok, got

Error message

Expected Ok, got {other:?}

What it means

A test assertion panic in the MCP server doctor tests: the test builds an HTTP/SSE MCP server definition (url = http://localhost:3000/mcp) and expects doctor_check_mcp_server to report McpServerDoctorStatus::Ok with a detail mentioning 'HTTP/SSE'. Any other status variant (Warning/Error) triggers panic!("Expected Ok, got {other:?}").

Solutions

  1. Print the full other:? status in the panic to see the doctor's reason.
  2. Check doctor_check_mcp_server for new network probing and ensure URL servers are validated structurally, not by connecting.
  3. Confirm the Ok detail string still includes 'HTTP/SSE' or update the assertion to the new wording.
  4. Run the test in isolation to rule out port conflicts with other tests.

Example fix

// before
other => panic!("Expected Ok, got {other:?}"),
// after
other => panic!("Expected Ok for url server, got {other:?}"),
Defensive patterns

Strategy: validation

Validate before calling

if !server.url.map_or(false, |u| u.starts_with("http")) {
    eprintln!("not a url server; doctor may not return Ok");
}

Type guard

fn is_url_server(s: &McpServer) -> bool {
    s.command.is_none() && s.url.is_some()
}

Try / catch

match doctor_check_mcp_server(&server) {
    McpServerDoctorStatus::Ok(d) => assert!(d.contains("HTTP/SSE"), "{d}"),
    other => panic!("Expected Ok, got {other:?}"),
}

Prevention

When it happens

Trigger: doctor_check_mcp_server(&server) returns Warning or Error for a well-formed URL server — e.g. the doctor now probes the URL, fails a health check, or misclassifies a URL-only server as missing a command.

Common situations: Doctor logic changed to actually connect and localhost:3000 has no listener in CI; a new validation warns on URL servers; the Ok detail text no longer contains 'HTTP/SSE'; offline CI environments.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/9c6d428bec0dea61. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:19377

            allow_private_network: false,
        }
    }

    #[test]
    fn test_no_command_or_url_is_error() {
        let server = make_server(None, &[], None);
        assert!(matches!(
            doctor_check_mcp_server(&server),
            McpServerDoctorStatus::Error(_)
        ));
    }

    #[test]
    fn test_url_server_is_ok() {
        let server = make_server(None, &[], Some("http://localhost:3000/mcp"));
        match doctor_check_mcp_server(&server) {
            McpServerDoctorStatus::Ok(detail) => assert!(detail.contains("HTTP/SSE")),
            other => panic!("Expected Ok, got {other:?}"),
        }
    }

    #[test]
    fn test_command_server_is_ok() {
        let executable = std::env::current_exe().expect("current test executable");
        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();

View on GitHub (pinned to 433685b202)