Hmbown/CodeWhale · info

recorded request

Error message

recorded request

What it means

This .expect("recorded request") is in crates/tui/src/client.rs:7806, unwrapping wiremock's server.received_requests() after the Codewhale chat call. It panics if the mock server cannot return its captured request log. The test then asserts exactly one request was made, validates its Bearer auth, and parses its JSON body.

Solutions

  1. Keep the MockServer alive in the test's scope until after received_requests() is awaited.
  2. Run this test alone (`cargo test -p codewhale-tui codewhale_chat`) to rule out cross-test interference.
  3. Check wiremock version compatibility for received_requests semantics.
  4. Remember the succeeding assert_eq!(requests.len(), 1) is a separate check — an Err here is a harness problem, not an HTTP problem.

Example fix

// before
let requests = server.received_requests().await.expect("recorded request");
// after
let requests = server.received_requests().await.unwrap_or_default();
assert_eq!(requests.len(), 1, "expected exactly one chat request");
Defensive patterns

Strategy: try-catch

Try / catch

let requests = server.received_requests().await.unwrap_or_default();
assert_eq!(requests.len(), 1, "expected exactly one recorded request");

Prevention

When it happens

Trigger: server.received_requests().await returning Err — the wiremock server's recorder is unavailable, usually because the server was dropped/reset before this await or a prior panic corrupted test state.

Common situations: Runtime/shutdown ordering issues in tokio tests; wiremock API version drift; refactoring the test so the server binding moves into a shorter-lived scope than the received_requests() call.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/c1aca44644124c36. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/client.rs:7806

                "choices": [{
                    "index": 0,
                    "message": {"role": "assistant", "content": "ok"},
                    "finish_reason": "stop"
                }],
                "usage": {"prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2}
            })))
            .expect(1)
            .mount(&server)
            .await;

        let client = codewhale_client(&server, "deepseek/deepseek-v4-pro");
        assert_eq!(client.wire_format, WireFormat::ChatCompletions);
        client
            .create_message(minimal_zen_request("deepseek/deepseek-v4-pro"))
            .await
            .expect("Codewhale chat request should succeed");

        let requests = server.received_requests().await.expect("recorded request");
        assert_eq!(requests.len(), 1);
        assert_codewhale_bearer(&requests[0]);
        let body: Value = serde_json::from_slice(&requests[0].body).expect("chat JSON body");
        // Model ids reach the account API exactly as its catalog returns them.
        assert_eq!(
            body.get("model").and_then(Value::as_str),
            Some("deepseek/deepseek-v4-pro")
        );
    }

    #[tokio::test]
    async fn codewhale_messages_request_carries_the_account_bearer_not_x_api_key() {
        let server = MockServer::start().await;
        Mock::given(method("POST"))
            .and(path("/v1/messages"))
            .respond_with(ResponseTemplate::new(200).set_body_json(json!({
                "id": "msg_cw",
                "type": "message",

View on GitHub (pinned to 73e0f67d83)