BoundaryML/baml · error
PostHog returned {status}
Error message
PostHog returned {status} What it means
`post_event` POSTs the feedback event to the PostHog `/capture/` endpoint and bails with this message when the HTTP response status is not a success (non-2xx). The status code is interpolated into the message (e.g. "PostHog returned 401 Unauthorized").
Source
Thrown at baml_language/crates/baml_cli/src/feedback_command.rs:920
"$set": { "email": email },
},
});
let _ = post_event(&body);
}
fn post_event(body: &Value) -> Result<()> {
let api_key = body["api_key"].as_str().unwrap_or("");
if api_key.trim().is_empty() {
anyhow::bail!("This build has no PostHog key configured.");
}
let resp = auth::http_client()
.post(format!("{}/capture/", posthog_host().trim_end_matches('/')))
.json(body)
.send()
.context("Failed to reach PostHog")?;
let status = resp.status();
if !status.is_success() {
anyhow::bail!("PostHog returned {status}");
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
fn send_args(
title: Option<&str>,
description: Option<&str>,
input: Option<&str>,
) -> FeedbackInner {
FeedbackInner {
action: None,
title: title.map(str::to_string),
description: description.map(str::to_string),
input: input.map(str::to_string),View on GitHub (pinned to bd85ce9dee)
Solutions
- Check the status in the message: 401/403 means the API key is wrong; 5xx means PostHog-side trouble.
- Retry later if the status is 5xx — the failure is transient.
- Verify the PostHog project API key baked into the build is still valid.
- If using a self-hosted/custom posthog_host, confirm the instance is reachable and serving /capture/.
Defensive patterns
Strategy: retry
Try / catch
match post_event(&body) {
Err(e) if e.to_string().contains("5") => schedule_retry(&body), // 5xx: retry later
Err(e) => eprintln!("PostHog error: {e}"),
Ok(()) => {}
} Prevention
- Verify the PostHog project API key is valid and not revoked.
- Monitor status.posthog.com or your self-hosted instance health before diagnosing locally.
- Add exponential backoff for 5xx statuses; do not retry 401/403.
- Pin and validate the posthog_host configuration for self-hosted setups.
When it happens
Trigger: PostHog responds with 401/403 (bad key), 4xx (malformed capture payload), or 5xx (service outage) to the POST to `{posthog_host}/capture/`.
Common situations: PostHog outage or degraded service, an invalid/revoked project API key, a proxy or corporate firewall rewriting the response, or a custom PostHog host (self-hosted) that is misconfigured.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Auth server returned {status}: {body}
- network error fetching {url}: {source}
- HTTP {status} fetching {url}
- baml.fetch_as: HTTP request failed: HTTP {} Body: {} at {:?}
- baml.fetch_as: HTTP request failed: HTTP {status} Body: {bod
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/b215d51b2bee1cf6.
Report an issue: GitHub.