{"record":{"id":"c1aca44644124c36","repo":"Hmbown/CodeWhale","slug":"recorded-request","errorCode":null,"errorMessage":"recorded request","messagePattern":"recorded request","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/tui/src/client.rs","lineNumber":7806,"sourceCode":"                \"choices\": [{\n                    \"index\": 0,\n                    \"message\": {\"role\": \"assistant\", \"content\": \"ok\"},\n                    \"finish_reason\": \"stop\"\n                }],\n                \"usage\": {\"prompt_tokens\": 1, \"completion_tokens\": 1, \"total_tokens\": 2}\n            })))\n            .expect(1)\n            .mount(&server)\n            .await;\n\n        let client = codewhale_client(&server, \"deepseek/deepseek-v4-pro\");\n        assert_eq!(client.wire_format, WireFormat::ChatCompletions);\n        client\n            .create_message(minimal_zen_request(\"deepseek/deepseek-v4-pro\"))\n            .await\n            .expect(\"Codewhale chat 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        let body: Value = serde_json::from_slice(&requests[0].body).expect(\"chat JSON body\");\n        // Model ids reach the account API exactly as its catalog returns them.\n        assert_eq!(\n            body.get(\"model\").and_then(Value::as_str),\n            Some(\"deepseek/deepseek-v4-pro\")\n        );\n    }\n\n    #[tokio::test]\n    async fn codewhale_messages_request_carries_the_account_bearer_not_x_api_key() {\n        let server = MockServer::start().await;\n        Mock::given(method(\"POST\"))\n            .and(path(\"/v1/messages\"))\n            .respond_with(ResponseTemplate::new(200).set_body_json(json!({\n                \"id\": \"msg_cw\",\n                \"type\": \"message\",","sourceCodeStart":7788,"sourceCodeEnd":7824,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L7788-L7824","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Keep the MockServer alive in the test's scope until after received_requests() is awaited.","Run this test alone (`cargo test -p codewhale-tui codewhale_chat`) to rule out cross-test interference.","Check wiremock version compatibility for received_requests semantics.","Remember the succeeding assert_eq!(requests.len(), 1) is a separate check — an Err here is a harness problem, not an HTTP problem."],"exampleFix":"// before\nlet requests = server.received_requests().await.expect(\"recorded request\");\n// after\nlet requests = server.received_requests().await.unwrap_or_default();\nassert_eq!(requests.len(), 1, \"expected exactly one chat request\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let requests = server.received_requests().await.unwrap_or_default();\nassert_eq!(requests.len(), 1, \"expected exactly one recorded request\");","preventionTips":["Keep the MockServer in scope through the final received_requests() call.","Avoid resetting or dropping the server between the client call and the assertion.","Check wiremock's changelog when upgrading; received_requests error semantics have changed across versions."],"tags":["rust","test","wiremock","mock-server"],"backgroundTag":"unexpected-response-shape","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"}