{"record":{"id":"eeb7856b632b43e8","repo":"Hmbown/CodeWhale","slug":"expected-doctor-command","errorCode":null,"errorMessage":"expected doctor command","messagePattern":"expected doctor command","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/main/tests.rs","lineNumber":82,"sourceCode":"    let config_arg = config_path.to_string_lossy().into_owned();\n\n    for suffix in [\n        Vec::<&str>::new(),\n        vec![\"--json\"],\n        vec![\"--context-json\"],\n        vec![\"--check-updates\"],\n        vec![\"--probe-mcp\"],\n    ] {\n        let mut argv = vec![\n            \"codewhale-tui\".to_string(),\n            \"--config\".to_string(),\n            config_arg.clone(),\n            \"doctor\".to_string(),\n        ];\n        argv.extend(suffix.iter().copied().map(str::to_string));\n        let cli = Cli::try_parse_from(argv).expect(\"offline doctor CLI\");\n        let Some(Commands::Doctor(args)) = cli.command.as_ref() else {\n            panic!(\"expected doctor command\");\n        };\n        let config = load_doctor_config_from_cli(&cli, args).expect(\"offline doctor config\");\n        assert!(config.http_headers.is_none());\n        assert!(config.sandbox_api_key.is_none());\n        assert!(\n            config\n                .search\n                .as_ref()\n                .and_then(|search| search.api_key.as_deref())\n                .is_none()\n        );\n        assert_eq!(\n            config.base_url.as_deref(),\n            Some(\"https://safe-doctor.example:9443/v1\")\n        );\n        assert_eq!(config.allow_shell, Some(false));\n        let rendered = format!(\"{config:?}\");\n        for sentinel in [","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/main/tests.rs#L64-L100","documentation":"Test panic in the offline-doctor CLI tests. The test parses an argv containing the \"doctor\" subcommand via Cli::try_parse_from and expects cli.command to be Some(Commands::Doctor). The let-else panic fires when parsing succeeded but the selected command is not Doctor — e.g. the argv was consumed by a different subcommand or the Doctor command was renamed/restructured.","triggerScenarios":"Cli::try_parse_from with args ending in \"doctor\" plus a --config flag yields a Commands variant other than Commands::Doctor(args).","commonSituations":"Renaming the Doctor command enum variant, changing argument order so a flag swallows \"doctor\", or the offline flag being parsed as the command.","solutions":["Print cli.command after parsing to see which variant was selected.","Verify the argv construction still places \"doctor\" as the subcommand and that --config precedes it correctly.","If the enum variant was renamed, update Commands::Doctor and the destructuring pattern together."],"exampleFix":"// before\nlet Some(Commands::Doctor(args)) = cli.command.as_ref() else { panic!(\"expected doctor command\"); };\n// after\nlet Some(Commands::Doctor(args)) = cli.command.as_ref() else { panic!(\"expected doctor command, got {:?}\", cli.command); };","handlingStrategy":"validation","validationCode":"let cli = Cli::try_parse_from(argv).expect(\"offline doctor CLI\");\nassert!(matches!(cli.command, Some(Commands::Doctor(_))), \"parsed command is not Doctor: {:?}\", cli.command);","typeGuard":"fn is_doctor(cli: &Cli) -> bool { matches!(cli.command, Some(Commands::Doctor(_))) }","tryCatchPattern":"let Some(Commands::Doctor(args)) = cli.command.as_ref() else { panic!(\"expected doctor command, got {:?}\", cli.command) };","preventionTips":["Build test argvs from a helper so subcommand placement cannot drift","Rename enum variants and their test usages in the same commit"],"tags":["rust","test-assertion","cli","clap"],"backgroundTag":"invalid-cli-argument","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"}