{"record":{"id":"b215d51b2bee1cf6","repo":"BoundaryML/baml","slug":"posthog-returned-status","errorCode":null,"errorMessage":"PostHog returned {status}","messagePattern":"PostHog returned (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/feedback_command.rs","lineNumber":920,"sourceCode":"            \"$set\": { \"email\": email },\n        },\n    });\n    let _ = post_event(&body);\n}\n\nfn post_event(body: &Value) -> Result<()> {\n    let api_key = body[\"api_key\"].as_str().unwrap_or(\"\");\n    if api_key.trim().is_empty() {\n        anyhow::bail!(\"This build has no PostHog key configured.\");\n    }\n    let resp = auth::http_client()\n        .post(format!(\"{}/capture/\", posthog_host().trim_end_matches('/')))\n        .json(body)\n        .send()\n        .context(\"Failed to reach PostHog\")?;\n    let status = resp.status();\n    if !status.is_success() {\n        anyhow::bail!(\"PostHog returned {status}\");\n    }\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    fn send_args(\n        title: Option<&str>,\n        description: Option<&str>,\n        input: Option<&str>,\n    ) -> FeedbackInner {\n        FeedbackInner {\n            action: None,\n            title: title.map(str::to_string),\n            description: description.map(str::to_string),\n            input: input.map(str::to_string),","sourceCodeStart":902,"sourceCodeEnd":938,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/feedback_command.rs#L902-L938","documentation":"`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\").","triggerScenarios":"PostHog responds with 401/403 (bad key), 4xx (malformed capture payload), or 5xx (service outage) to the POST to `{posthog_host}/capture/`.","commonSituations":"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.","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/."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match post_event(&body) {\n  Err(e) if e.to_string().contains(\"5\") => schedule_retry(&body), // 5xx: retry later\n  Err(e) => eprintln!(\"PostHog error: {e}\"),\n  Ok(()) => {}\n}","preventionTips":["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."],"tags":["http","posthog","network"],"backgroundTag":"http-error-response","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}