{"record":{"id":"4fda9daaab3d1993","repo":"Hmbown/CodeWhale","slug":"expected-ok-when-cwd-anchors-relative-path-got-other","errorCode":null,"errorMessage":"Expected Ok when cwd anchors relative path, got {other:?}","messagePattern":"Expected Ok when cwd anchors relative path, got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":19456,"sourceCode":"            assert!(\n                matches!(\n                    doctor_check_mcp_server(&server),\n                    McpServerDoctorStatus::Warning(_)\n                ),\n                \"Expected a relative-path warning for {command} {argument}\"\n            );\n        }\n    }\n\n    #[test]\n    fn test_relative_stdio_path_arg_with_cwd_is_ok() {\n        let executable = std::env::current_exe().expect(\"current test executable\");\n        let executable = executable.to_string_lossy();\n        let mut server = make_server(Some(&executable), &[\"server/mcp_server.py\"], None);\n        server.cwd = Some(PathBuf::from(\"/tmp/codewhale-project\"));\n        match doctor_check_mcp_server(&server) {\n            McpServerDoctorStatus::Ok(detail) => assert!(detail.contains(\"stdio\")),\n            other => panic!(\"Expected Ok when cwd anchors relative path, got {other:?}\"),\n        }\n    }\n\n    #[test]\n    fn test_self_hosted_absolute_is_ok() {\n        let executable = std::env::current_exe().expect(\"current test executable\");\n        let executable = executable.to_string_lossy();\n        let server = make_server(Some(&executable), &[\"serve\", \"--mcp\"], None);\n        match doctor_check_mcp_server(&server) {\n            McpServerDoctorStatus::Ok(detail) => assert!(detail.contains(\"stdio server\")),\n            McpServerDoctorStatus::Warning(detail) => {\n                panic!(\"Absolute path should not warn: {detail}\")\n            }\n            McpServerDoctorStatus::Error(detail) => panic!(\"unexpected error: {detail}\"),\n        }\n    }\n\n    #[cfg(test)]","sourceCodeStart":19438,"sourceCodeEnd":19474,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/lib.rs#L19438-L19474","documentation":"Test panic asserting that when an MCP server command is a relative path (e.g. server/mcp_server.py), providing a cwd (server.cwd = Some(\"/tmp/codewhale-project\")) makes doctor_check_mcp_server classify it as Ok (stdio) rather than warning about an unanchored relative path. The panic fires when any non-Ok variant is returned.","triggerScenarios":"Calling doctor_check_mcp_server on an McpServerConfig whose command is a relative path and whose cwd is set; the doctor returns Warning/Error instead of resolving the relative path against cwd and returning Ok.","commonSituations":"Regression in the doctor's relative-path-vs-cwd resolution logic; cwd field dropped or ignored during a config refactor; test executable path handling changed.","solutions":["Read the {other:?} payload in the panic message to see the actual Warning/Error detail.","Verify doctor_check_mcp_server consults server.cwd before flagging relative command paths.","If relative-path-with-cwd should now warn by policy, update the test to the new expectation."],"exampleFix":"// before\nserver.cwd = Some(PathBuf::from(\"/tmp/codewhale-project\"));\n// after (if the doctor needs the cwd to exist)\n// ensure the anchor directory exists in the test environment:\nstd::fs::create_dir_all(\"/tmp/codewhale-project\").ok();","handlingStrategy":"validation","validationCode":"if Path::new(cmd).is_relative() && server.cwd.is_none() { // expect a warning, not Ok }","typeGuard":"fn is_ok_status(s: &McpServerDoctorStatus) -> bool { matches!(s, McpServerDoctorStatus::Ok(_)) }","tryCatchPattern":"match doctor_check_mcp_server(&server) { Ok(d) => assert!(d.contains(\"stdio\")), other => panic!(\"cwd-anchored relative path misclassified: {other:?}\") }","preventionTips":["Always set cwd when using relative MCP server commands","Test the cwd-resolution branch separately from the absolute-path branch"],"tags":["rust","test-assertion","mcp","panic"],"backgroundTag":"unexpected-response-shape","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}