Hmbown/CodeWhale · info

health check

Error message

health check

What it means

This .expect("health check") is inside the tokio test concentrate_health_check_does_not_treat_unauthenticated_models_as_key_proof in crates/tui/src/client.rs:7683. It unwraps the Result from ConcentrateClient::health_check(); the test asserts the health check succeeds (returns Ok(true)) while proving it did NOT issue a request. A panic here means health_check returned Err or Ok(false) when it was expected to resolve locally without network key verification.

Solutions

  1. Inspect what health_check returned: an Err points at request construction/transport; Ok(false) points at the verification predicate.
  2. Confirm the fix under test: health_check must not issue GET /v1/models; the next assertion (`!provider_api_key_verification_is_observed`) plus empty request list is the real check.
  3. Re-run only this test (`cargo test -p codewhale-tui concentrate_health_check`) to see the panic line in isolation.
  4. If an intended behavior change makes unauthenticated /v1/models count as verification, update the test to encode the new contract rather than the code.

Example fix

// before
assert!(client.health_check().await.expect("health check"));
// after
let healthy = client.health_check().await.expect("health check");
assert!(healthy, "health_check returned false: {:?}", healthy);
Defensive patterns

Strategy: validation

Validate before calling

// caller-side guard before relying on health_check as key proof
let healthy = client.health_check().await?;
if !healthy {
    return Err(anyhow!("concentrate health check returned false; unauthenticated /v1/models is not key verification"));
}

Try / catch

// match on the Result instead of expect
match client.health_check().await {
    Ok(true) => { /* proceed */ }
    Ok(false) => eprintln!("health check returned false"),
    Err(e) => eprintln!("health check failed: {e}"),
}

Prevention

When it happens

Trigger: Calling health_check() on a Concentrate client pointed at a mock server; the expect fires if health_check returns Err (request/build failure) or Ok(false) — e.g. a code change makes health_check hit GET /v1/models and treat an unauthenticated 200 as proof of a valid key, altering the return path.

Common situations: Refactoring health-check logic so it treats any successful model-list response as key verification; breaking client construction in the test fixture; wiremock mock not mounted so the request 404s; running the test offline and an unintended real request failing.

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/52d040302d6b21cd. Report an issue: GitHub.

Appendix: source

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

                "HTTP {status}: message must carry the documented text, got: {message}"
            );
            assert_eq!(
                crate::error_taxonomy::classify_error_message(&message),
                expected,
                "HTTP {status}: {message}"
            );
        }
    }

    /// Concentrate's `GET /v1/models` is unauthenticated, so a 2xx must not
    /// count as key verification. Guided setup treats the probe as unobserved;
    /// health_check must not issue the request either.
    #[tokio::test]
    async fn concentrate_health_check_does_not_treat_unauthenticated_models_as_key_proof() {
        let server = MockServer::start().await;
        let client = concentrate_client(&server, DEFAULT_CONCENTRATE_MODEL);

        assert!(client.health_check().await.expect("health check"));
        assert!(!provider_api_key_verification_is_observed(
            ApiProvider::Concentrate
        ));
        let requests = server.received_requests().await.expect("recorded requests");
        assert!(
            requests.is_empty(),
            "Concentrate must not treat unauthenticated GET /v1/models as key verification"
        );
    }

    /// `GET /v1/models` needs no key and answers the OpenAI list shape; rows
    /// are provider-scoped, the default is marked, and unknowns stay unclaimed.
    /// https://concentrate.ai/docs/api-reference/endpoint/list-models
    #[tokio::test]
    async fn concentrate_live_catalog_is_provider_scoped_and_marks_the_default() {
        let server = MockServer::start().await;
        Mock::given(method("GET"))
            .and(path("/v1/models"))

View on GitHub (pinned to 73e0f67d83)