Hmbown/CodeWhale · error
Codewhale messages request should succeed
Error message
Codewhale messages request should succeed
What it means
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.
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
Example fix
// before
client.create_message(minimal_zen_request("anthropic/claude-sonnet-5")).await
.expect("Codewhale messages request should succeed");
// after
let resp = client.create_message(minimal_zen_request("anthropic/claude-sonnet-5")).await
.unwrap_or_else(|e| panic!("Codewhale messages request should succeed: {e:?}")); Defensive patterns
Strategy: try-catch
Validate before calling
assert_eq!(client.wire_format, WireFormat::AnthropicMessages); // ensure a mock route exists for the exact method+path before calling
Type guard
fn expect_ok<T>(r: Result<T, impl std::fmt::Debug>) -> T {
r.unwrap_or_else(|e| panic!("messages request failed: {e:?}"))
} Try / catch
match client.create_message(req).await {
Ok(resp) => resp,
Err(e) => panic!("Codewhale messages request should succeed: {e:?}"),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Codewhale chat request should succeed
- Codewhale responses request should succeed
- failed to build HTTP client
- Failed to list models: HTTP
- generated mobile cookie is a valid header
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/34050dee65c5d27c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/client.rs:7841
"id": "msg_cw",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "ok"}],
"model": "anthropic/claude-sonnet-5",
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {"input_tokens": 1, "output_tokens": 1}
})))
.expect(1)
.mount(&server)
.await;
let client = codewhale_client(&server, "anthropic/claude-sonnet-5");
assert_eq!(client.wire_format, WireFormat::AnthropicMessages);
client
.create_message(minimal_zen_request("anthropic/claude-sonnet-5"))
.await
.expect("Codewhale messages request should succeed");
let requests = server.received_requests().await.expect("recorded request");
assert_eq!(requests.len(), 1);
assert_codewhale_bearer(&requests[0]);
assert_eq!(
requests[0]
.headers
.get("anthropic-version")
.and_then(|value| value.to_str().ok()),
Some("2023-06-01")
);
}
/// A catalog row stating `codewhale.protocol = "responses"` must dispatch
/// to the account API's Responses surface — `{base}/responses` — not the
/// Chat Completions default its `openai/` namespace alone would imply.
#[tokio::test]
async fn codewhale_responses_catalog_row_dispatches_to_responses_endpoint() {View on GitHub (pinned to 73e0f67d83)