{"record":{"id":"0c50052a9f47816d","repo":"Hmbown/CodeWhale","slug":"zen-messages-request-should-succeed","errorCode":null,"errorMessage":"Zen Messages request should succeed","messagePattern":"Zen Messages request should succeed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client.rs","lineNumber":8170,"sourceCode":"                \"id\": \"msg_zen\",\n                \"type\": \"message\",\n                \"role\": \"assistant\",\n                \"content\": [{\"type\": \"text\", \"text\": \"ok\"}],\n                \"model\": \"claude-sonnet-4-6\",\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 = opencode_zen_client(&server, \"claude-sonnet-4-6\");\n        assert_eq!(client.wire_format, WireFormat::AnthropicMessages);\n        client\n            .create_message(minimal_zen_request(\"claude-sonnet-4-6\"))\n            .await\n            .expect(\"Zen Messages request should succeed\");\n\n        let requests = server.received_requests().await.expect(\"recorded request\");\n        assert_eq!(requests.len(), 1);\n        assert_zen_messages_api_key_without_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    #[tokio::test]\n    async fn opencode_zen_chat_request_uses_chat_completions_route() {\n        let server = MockServer::start().await;\n        Mock::given(method(\"POST\"))\n            .and(path(\"/v1/chat/completions\"))","sourceCodeStart":8152,"sourceCodeEnd":8188,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/client.rs#L8152-L8188","documentation":"Test-side `.expect(\"Zen Messages request should succeed\")` panic. `create_message` returned `Err` for a `WireFormat::AnthropicMessages` client hitting the mocked `/v1/messages` endpoint. The non-streaming Anthropic Messages path failed to complete, either before sending (route/auth resolution) or on a non-2xx/unparseable response.","triggerScenarios":"Running `opencode_zen_messages_request_shape_uses_api_key_anthropic_route` when the mock route path no longer matches (`/v1/messages`), the client resolves a different wire format for claude-sonnet-4-6, or the mocked JSON response no longer satisfies the Messages response parser (missing `content`, `stop_reason`, or `usage` fields).","commonSituations":"Changing the Anthropic response schema the parser expects; route constants or base_url changes; mock fixture edited so required fields (`id`, `type`, `role`, `content`, `usage`) are missing.","solutions":["Print the error (`{e:?}`) to distinguish send failure from response-parse failure.","Verify the mock mounted at `POST /v1/messages` returns the full Anthropic Messages JSON fixture including `usage`.","Confirm `client.wire_format == WireFormat::AnthropicMessages` (asserted above) so the request targets `/v1/messages`.","If the client's auth changed, remember Messages uses `x-api-key` + `anthropic-version`, not Bearer."],"exampleFix":"// before\nclient\n    .create_message(minimal_zen_request(\"claude-sonnet-4-6\"))\n    .await\n    .expect(\"Zen Messages request should succeed\");\n// after\nclient\n    .create_message(minimal_zen_request(\"claude-sonnet-4-6\"))\n    .await\n    .unwrap_or_else(|e| panic!(\"Zen Messages request should succeed: {e:?}\"));","handlingStrategy":"try-catch","validationCode":"// Rust (preconditions)\nassert_eq!(client.wire_format, WireFormat::AnthropicMessages);\n// fixture must satisfy the parser:\nassert!(fixture.get(\"usage\").is_some() && fixture.get(\"content\").is_some());","typeGuard":null,"tryCatchPattern":"match client.create_message(req).await {\n    Ok(msg) => assert!(!msg.content.is_empty()),\n    Err(e) => panic!(\"Messages request should succeed: {e:?}\"),\n}","preventionTips":["Keep the Anthropic Messages fixture complete: id, type, role, content, stop_reason, usage.","Update the response parser and fixtures in the same commit.","Assert wire_format before the call to catch route misresolution early.","Remember Messages auth is x-api-key + anthropic-version, not Bearer."],"tags":["test-assertion","anthropic","http","rust"],"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"}