{"record":{"id":"52d040302d6b21cd","repo":"Hmbown/CodeWhale","slug":"health-check","errorCode":null,"errorMessage":"health check","messagePattern":"health check","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/tui/src/client.rs","lineNumber":7683,"sourceCode":"                \"HTTP {status}: message must carry the documented text, got: {message}\"\n            );\n            assert_eq!(\n                crate::error_taxonomy::classify_error_message(&message),\n                expected,\n                \"HTTP {status}: {message}\"\n            );\n        }\n    }\n\n    /// Concentrate's `GET /v1/models` is unauthenticated, so a 2xx must not\n    /// count as key verification. Guided setup treats the probe as unobserved;\n    /// health_check must not issue the request either.\n    #[tokio::test]\n    async fn concentrate_health_check_does_not_treat_unauthenticated_models_as_key_proof() {\n        let server = MockServer::start().await;\n        let client = concentrate_client(&server, DEFAULT_CONCENTRATE_MODEL);\n\n        assert!(client.health_check().await.expect(\"health check\"));\n        assert!(!provider_api_key_verification_is_observed(\n            ApiProvider::Concentrate\n        ));\n        let requests = server.received_requests().await.expect(\"recorded requests\");\n        assert!(\n            requests.is_empty(),\n            \"Concentrate must not treat unauthenticated GET /v1/models as key verification\"\n        );\n    }\n\n    /// `GET /v1/models` needs no key and answers the OpenAI list shape; rows\n    /// are provider-scoped, the default is marked, and unknowns stay unclaimed.\n    /// https://concentrate.ai/docs/api-reference/endpoint/list-models\n    #[tokio::test]\n    async fn concentrate_live_catalog_is_provider_scoped_and_marks_the_default() {\n        let server = MockServer::start().await;\n        Mock::given(method(\"GET\"))\n            .and(path(\"/v1/models\"))","sourceCodeStart":7665,"sourceCodeEnd":7701,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L7665-L7701","documentation":"This .expect(\"health check\") is inside the tokio test concentrate_health_check_does_not_treat_unauthenticated_models_as_key_proof in crates/tui/src/client.rs:7683. It unwraps the Result from ConcentrateClient::health_check(); the test asserts the health check succeeds (returns Ok(true)) while proving it did NOT issue a request. A panic here means health_check returned Err or Ok(false) when it was expected to resolve locally without network key verification.","triggerScenarios":"Calling health_check() on a Concentrate client pointed at a mock server; the expect fires if health_check returns Err (request/build failure) or Ok(false) — e.g. a code change makes health_check hit GET /v1/models and treat an unauthenticated 200 as proof of a valid key, altering the return path.","commonSituations":"Refactoring health-check logic so it treats any successful model-list response as key verification; breaking client construction in the test fixture; wiremock mock not mounted so the request 404s; running the test offline and an unintended real request failing.","solutions":["Inspect what health_check returned: an Err points at request construction/transport; Ok(false) points at the verification predicate.","Confirm the fix under test: health_check must not issue GET /v1/models; the next assertion (`!provider_api_key_verification_is_observed`) plus empty request list is the real check.","Re-run only this test (`cargo test -p codewhale-tui concentrate_health_check`) to see the panic line in isolation.","If an intended behavior change makes unauthenticated /v1/models count as verification, update the test to encode the new contract rather than the code."],"exampleFix":"// before\nassert!(client.health_check().await.expect(\"health check\"));\n// after\nlet healthy = client.health_check().await.expect(\"health check\");\nassert!(healthy, \"health_check returned false: {:?}\", healthy);","handlingStrategy":"validation","validationCode":"// caller-side guard before relying on health_check as key proof\nlet healthy = client.health_check().await?;\nif !healthy {\n    return Err(anyhow!(\"concentrate health check returned false; unauthenticated /v1/models is not key verification\"));\n}","typeGuard":null,"tryCatchPattern":"// match on the Result instead of expect\nmatch client.health_check().await {\n    Ok(true) => { /* proceed */ }\n    Ok(false) => eprintln!(\"health check returned false\"),\n    Err(e) => eprintln!(\"health check failed: {e}\"),\n}","preventionTips":["Never treat a successful unauthenticated GET /v1/models as proof an API key works.","Keep health checks that must not issue network requests purely local and assert that with request-recording mocks.","When changing health-check semantics, update the contract test and the provider verification flag together."],"tags":["rust","test","health-check","wiremock"],"backgroundTag":"http-request-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}