{"record":{"id":"34050dee65c5d27c","repo":"Hmbown/CodeWhale","slug":"codewhale-messages-request-should-succeed","errorCode":null,"errorMessage":"Codewhale messages request should succeed","messagePattern":"Codewhale messages request should succeed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":7841,"sourceCode":"                \"id\": \"msg_cw\",\n                \"type\": \"message\",\n                \"role\": \"assistant\",\n                \"content\": [{\"type\": \"text\", \"text\": \"ok\"}],\n                \"model\": \"anthropic/claude-sonnet-5\",\n                \"stop_reason\": \"end_turn\",\n                \"stop_sequence\": null,\n                \"usage\": {\"input_tokens\": 1, \"output_tokens\": 1}\n            })))\n            .expect(1)\n            .mount(&server)\n            .await;\n\n        let client = codewhale_client(&server, \"anthropic/claude-sonnet-5\");\n        assert_eq!(client.wire_format, WireFormat::AnthropicMessages);\n        client\n            .create_message(minimal_zen_request(\"anthropic/claude-sonnet-5\"))\n            .await\n            .expect(\"Codewhale messages request should succeed\");\n\n        let requests = server.received_requests().await.expect(\"recorded request\");\n        assert_eq!(requests.len(), 1);\n        assert_codewhale_bearer(&requests[0]);\n        assert_eq!(\n            requests[0]\n                .headers\n                .get(\"anthropic-version\")\n                .and_then(|value| value.to_str().ok()),\n            Some(\"2023-06-01\")\n        );\n    }\n\n    /// A catalog row stating `codewhale.protocol = \"responses\"` must dispatch\n    /// to the account API's Responses surface — `{base}/responses` — not the\n    /// Chat Completions default its `openai/` namespace alone would imply.\n    #[tokio::test]\n    async fn codewhale_responses_catalog_row_dispatches_to_responses_endpoint() {","sourceCodeStart":7823,"sourceCodeEnd":7859,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L7823-L7859","documentation":"This `expect` panics when `client.create_message(...)` returns `Err` while sending an Anthropic-messages-format request through the Codewhale client, aborting the test with 'Codewhale messages request should succeed'. The client retries/fails the HTTP call and the test treats any error as a hard failure because the mock server is configured to always succeed.","triggerScenarios":"Calling `create_message` on a `CodewhaleClient` with `wire_format == WireFormat::AnthropicMessages` (crates/tui/src/client.rs:7841) when the mock server returns a non-2xx status, the request cannot be built, the connection fails, or all retries are exhausted.","commonSituations":"Mock route not registered so wiremock returns 404; missing `anthropic-version` handling; wrong base URL or API key in the test config; TLS or socket errors in CI.","solutions":["Check the mock server's registered routes match the request path/method the client actually sends","Assert on the returned `Err` payload to see the HTTP status or transport error","Verify bearer token and base URL setup in the `codewhale_client` helper","Ensure required headers (e.g. anthropic-version) are accepted by the mock"],"exampleFix":"// before\nclient.create_message(minimal_zen_request(\"anthropic/claude-sonnet-5\")).await\n    .expect(\"Codewhale messages request should succeed\");\n// after\nlet resp = client.create_message(minimal_zen_request(\"anthropic/claude-sonnet-5\")).await\n    .unwrap_or_else(|e| panic!(\"Codewhale messages request should succeed: {e:?}\"));","handlingStrategy":"try-catch","validationCode":"assert_eq!(client.wire_format, WireFormat::AnthropicMessages);\n// ensure a mock route exists for the exact method+path before calling","typeGuard":"fn expect_ok<T>(r: Result<T, impl std::fmt::Debug>) -> T {\n    r.unwrap_or_else(|e| panic!(\"messages request failed: {e:?}\"))\n}","tryCatchPattern":"match client.create_message(req).await {\n    Ok(resp) => resp,\n    Err(e) => panic!(\"Codewhale messages request should succeed: {e:?}\"),\n}","preventionTips":["Register mock routes before issuing client requests","Assert wire_format before calling to catch routing mistakes","Log client errors instead of bare expect for debuggability"],"tags":["rust","http","api-test"],"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-22T11:17:16.035Z"}