{"record":{"id":"225b5bf4bcd7f338","repo":"Hmbown/CodeWhale","slug":"expected-authentication-error-got-other","errorCode":null,"errorMessage":"expected authentication error, got {other}","messagePattern":"expected authentication error, got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/llm_client/mod.rs","lineNumber":1380,"sourceCode":"mod quota_tests;\n\n// === Tests ===\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    fn assert_f64_eq(actual: f64, expected: f64) {\n        assert!(\n            (actual - expected).abs() < f64::EPSILON,\n            \"expected {expected}, got {actual}\"\n        );\n    }\n\n    fn auth_user_message(error: LlmError) -> String {\n        match error {\n            LlmError::AuthenticationError(auth) => auth.to_user_message(),\n            other => panic!(\"expected authentication error, got {other}\"),\n        }\n    }\n\n    #[test]\n    fn test_retry_config_defaults() {\n        let config = RetryConfig::default();\n        assert!(config.enabled);\n        assert_eq!(config.max_retries, 3);\n        assert_f64_eq(config.initial_delay, 1.0);\n        assert_f64_eq(config.max_delay, 60.0);\n        assert_f64_eq(config.exponential_base, 2.0);\n        assert!(config.jitter);\n    }\n\n    #[test]\n    fn test_retry_config_disabled() {\n        let config = RetryConfig::disabled();\n        assert!(!config.enabled);","sourceCodeStart":1362,"sourceCodeEnd":1398,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/llm_client/mod.rs#L1362-L1398","documentation":"Test helper panic in the LLM client's auth-message tests. auth_user_message takes an LlmError and only handles LlmError::AuthenticationError; any other variant (rate limit, network, API error) hits the catch-all panic. It exists so a test author passing the wrong LlmError variant fails loudly instead of testing the wrong message path.","triggerScenarios":"A test calls auth_user_message with an LlmError that is not LlmError::AuthenticationError — typically after refactoring where a helper now receives a different error variant.","commonSituations":"Changing which error a retry/client path produces (e.g. from AuthenticationError to ApiError) without updating the helper's caller; copy-paste of a helper call across tests.","solutions":["Check which test calls auth_user_message and fix the LlmError it constructs to be LlmError::AuthenticationError.","If the client now surfaces a different variant for auth failures, update both the helper and the expectation.","Optionally have the panic print Debug of `other` for quick diagnosis."],"exampleFix":"// before\nother => panic!(\"expected authentication error, got {other}\"),\n// after\nother => panic!(\"expected authentication error, got {other:?} — the client now maps auth failures to a different LlmError variant\"),","handlingStrategy":"type-guard","validationCode":"// ensure the constructed error is the auth variant before calling the helper\nassert!(matches!(err, LlmError::AuthenticationError(_)), \"helper requires AuthenticationError, got {err:?}\");","typeGuard":"fn is_auth_error(e: &LlmError) -> bool { matches!(e, LlmError::AuthenticationError(_)) }","tryCatchPattern":"match error { LlmError::AuthenticationError(a) => a.to_user_message(), other => panic!(\"expected authentication error, got {other:?}\") }","preventionTips":["Construct test errors with dedicated constructors instead of literals","Keep LlmError variants in sync with tests when mapping logic changes"],"tags":["rust","test-assertion","errors","authentication"],"backgroundTag":"type-mismatch","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"}