{"record":{"id":"fd23dd66ced485a5","repo":"thanos-io/thanos","slug":"bad-response-status-v-from-q","errorCode":null,"errorMessage":"bad response status %v from %q","messagePattern":"bad response status (.+?) from %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/alert/alert.go","lineNumber":399,"sourceCode":"\nfunc (a *Alertmanager) postAlerts(ctx context.Context, u url.URL, r io.Reader) error {\n\treq, err := http.NewRequest(\"POST\", u.String(), r)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := context.WithTimeout(ctx, a.timeout)\n\tdefer cancel()\n\treq = req.WithContext(ctx)\n\treq.Header.Set(\"Content-Type\", contentTypeJSON)\n\n\tresp, err := a.dispatcher.Do(req)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"send request to %q\", u.String())\n\t}\n\tdefer runutil.ExhaustCloseWithLogOnErr(a.logger, resp.Body, \"send one alert\")\n\n\tif resp.StatusCode/100 != 2 {\n\t\treturn errors.Errorf(\"bad response status %v from %q\", resp.Status, u.String())\n\t}\n\treturn nil\n}\n","sourceCodeStart":381,"sourceCodeEnd":403,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/alert/alert.go#L381-L403","documentation":"After a successful alert POST, postAlerts checks the response status and requires a 2xx code. Any non-2xx (404 wrong path, 401 auth, 429 rate limit, 5xx) yields this error carrying the status line and target URL.","triggerScenarios":"The Alertmanager (or proxy in front of it) returned e.g. 404 because the URL path is wrong, 401/403 because auth is required, or 5xx because it failed to process the alert batch.","commonSituations":"Alertmanager behind a reverse proxy requiring basic auth or mTLS the sender doesn't provide; URL configured with wrong path prefix; target Alertmanager rejecting payloads due to limits; version mismatch between API groups.","solutions":["Read the status code in the message: 404 means wrong URL/path, 401/403 means configure credentials, 429 means reduce alert volume, 5xx means check Alertmanager logs.","Verify the alertmanager URL includes the correct path (e.g. /api/v2/alerts is handled internally) and scheme.","Configure the dispatcher's RoundTripper with the required auth (basic auth, TLS client certs).","Check target Alertmanager logs/metrics for the corresponding request failure to see why it rejected the batch."],"exampleFix":"// before\nurls: http://alertmanager:9093/alertmanager\n// after (correct base URL without extra path)\nurls: http://alertmanager:9093","handlingStrategy":"try-catch","validationCode":"// verify endpoint before posting\nresp, err := http.Head(strings.TrimSuffix(amURL, \"/\") + \"/-/ready\")\nif err != nil || resp.StatusCode/100 != 2 {\n    return fmt.Errorf(\"alertmanager %s not healthy\", amURL)\n}","typeGuard":null,"tryCatchPattern":"if err := sender.postAlerts(ctx, alerts); err != nil {\n    if strings.Contains(err.Error(), \"status 429\") {\n        // back off and retry later\n    } else if strings.Contains(err.Error(), \"status 404\") {\n        // fix URL config; do not retry\n    }\n    return err\n}","preventionTips":["Confirm the full alertmanager URL/path against the running version's API.","Configure auth (basic auth, client certs) required by any proxy in front.","Watch Alertmanager-side rate limits and alert ingestion limits.","Check target Alertmanager logs for 5xx root causes."],"tags":["http","alerts","status-code"],"backgroundTag":"http-error-response","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}