Hmbown/CodeWhale · error

Zen Responses request should start

Error message

Zen Responses request should start

What it means

Test-side `.expect("Zen Responses request should start")` panic. `create_message_stream` returned `Err`, meaning the client could not establish the streaming request against the mocked `/v1/responses` endpoint. Because the wire format is `WireFormat::Responses`, this is the SSE-streaming path failing before any events are produced.

Solutions

  1. Check that `Mock::given(method("POST")).and(path("/v1/responses"))` still matches the URL the client builds from its base_url.
  2. Verify `client.wire_format == WireFormat::Responses` before the call (asserted just above) and that route resolution maps gpt-5.5 to the Responses endpoint.
  3. Print the error (`{:?}`) from `create_message_stream` to see whether it is connection, routing, or auth related.
  4. Confirm the mock server is started and mounted before `create_message_stream` is awaited.

Example fix

// before
let mut stream = client
    .create_message_stream(minimal_zen_request("gpt-5.5"))
    .await
    .expect("Zen Responses request should start");
// after (debugging)
let mut stream = client
    .create_message_stream(minimal_zen_request("gpt-5.5"))
    .await
    .unwrap_or_else(|e| panic!("Zen Responses request should start: {e:?}"));
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust (preconditions in test)
assert_eq!(client.wire_format, WireFormat::Responses, "model must resolve to Responses wire");
assert!(Mock::given(method("POST")).and(path("/v1/responses")).matches(), "route must be mounted");

Try / catch

match client.create_message_stream(req).await {
    Ok(stream) => { /* consume */ }
    Err(e) => panic!("stream should start: {e:?}"),
}

Prevention

When it happens

Trigger: Running `opencode_zen_responses_request_uses_responses_route_without_oauth_headers` when the mock route is not mounted at the path the client resolves (e.g. `/v1/responses`), the client picks the wrong wire format/route, connection setup fails, or the model route resolution errors (model not bound to Responses protocol).

Common situations: Changing base URL or route constants so the mock no longer matches; renaming the helper `opencode_zen_client`'s configured model so route resolution no longer maps to Responses; TLS/port or tokio runtime issues in the test harness.

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


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

Appendix: source

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

    async fn opencode_zen_responses_request_uses_responses_route_without_oauth_headers() {
        let server = MockServer::start().await;
        Mock::given(method("POST"))
            .and(path("/v1/responses"))
            .respond_with(
                ResponseTemplate::new(200)
                    .insert_header("Content-Type", "text/event-stream")
                    .set_body_string("data: [DONE]\n\n"),
            )
            .expect(1)
            .mount(&server)
            .await;

        let client = opencode_zen_client(&server, "gpt-5.5");
        assert_eq!(client.wire_format, WireFormat::Responses);
        let mut stream = client
            .create_message_stream(minimal_zen_request("gpt-5.5"))
            .await
            .expect("Zen Responses request should start");
        while let Some(event) = stream.next().await {
            event.expect("Zen Responses stream event");
        }

        let requests = server.received_requests().await.expect("recorded request");
        assert_eq!(requests.len(), 1);
        assert_zen_bearer_without_codex_headers(&requests[0]);
        let body: Value = serde_json::from_slice(&requests[0].body).expect("Responses JSON body");
        assert_eq!(body.get("model").and_then(Value::as_str), Some("gpt-5.5"));
        assert!(body.get("input").is_some(), "Responses body: {body}");
        assert!(body.get("messages").is_none(), "Responses body: {body}");
    }

    #[tokio::test]
    async fn opencode_zen_messages_request_shape_uses_api_key_anthropic_route() {
        let server = MockServer::start().await;
        Mock::given(method("POST"))
            .and(path("/v1/messages"))

View on GitHub (pinned to 73e0f67d83)