tinyhumansai/openhuman · error · anyhow::Error

API base URL must be an absolute http(s) URL with host

Error message

API base URL must be an absolute http(s) URL with host

What it means

The api_base supplied to BackendOAuthClient did not parse as an absolute http(s) URL with a host, so there is no valid origin to join backend-relative REST paths against; initialization fails immediately.

Solutions

  1. Pass an absolute origin such as https://api.example.com
  2. Include the scheme; a bare hostname is not sufficient
  3. Check the backend URL environment variable for truncation
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/api/rest.rs:415 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/a16b79e64a742395. Report an issue: GitHub.

Appendix: source

Thrown at src/api/rest.rs:415

#[derive(Clone)]
pub struct BackendOAuthClient {
    client: Client,
    base: Url,
    sdk: TinyHumansClient,
}

impl BackendOAuthClient {
    /// Creates a new `BackendOAuthClient` with the given API base URL.
    ///
    /// Any path, query, or fragment in `api_base` is stripped so that
    /// `Url::join` always resolves root-relative REST paths correctly.
    /// This guards against callers who pass a full LLM completions URL
    /// (e.g. `https://host/v1/chat/completions`) instead of just the origin:
    /// without stripping, `join("teams/me/usage")` would produce the wrong
    /// path `/v1/chat/teams/me/usage` via RFC 3986 relative resolution.
    pub fn new(api_base: &str) -> Result<Self> {
        let mut base = Url::parse(api_base.trim()).context("Invalid API base URL")?;
        anyhow::ensure!(
            matches!(base.scheme(), "http" | "https") && base.host_str().is_some(),
            "API base URL must be an absolute http(s) URL with host"
        );
        base.set_path("");
        base.set_query(None);
        base.set_fragment(None);
        let client = build_backend_reqwest_client()?;
        // The product identity also rides on the SDK's own default headers, not
        // just the transport's, so it survives if the SDK is ever given a
        // client this crate did not build. The SDK applies its own headers
        // after these, so it cannot be clobbered by `x-sdk-client`.
        let sdk = TinyHumansClient::new(base.as_str())
            .with_http_client(client.clone())
            .with_default_headers(crate::api::product::product_identity_headers());
        Ok(Self { client, base, sdk })
    }

    /// Borrow the underlying `reqwest::Client` for callers that need to

View on GitHub (pinned to 7491200858)