{"record":{"id":"49212cce19b7a0f7","repo":"chenhg5/cc-connect","slug":"cloud-web-send-http-d-s","errorCode":null,"errorMessage":"cloud_web: send HTTP %d: %s","messagePattern":"cloud_web: send HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/cloud-web/gateway.go","lineNumber":285,"sourceCode":"\tbody, err := json.Marshal(msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\turl := joinURL(t.baseURL, t.sendPath)\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tauthHTTP(req, t.token)\n\tresp, err := t.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\traw, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\n\tif resp.StatusCode >= 300 {\n\t\treturn fmt.Errorf(\"cloud_web: send HTTP %d: %s\", resp.StatusCode, string(raw))\n\t}\n\tvar ack wirePreviewAck\n\tif json.Unmarshal(raw, &ack) == nil && ack.Type == \"preview_ack\" && ack.RefID != \"\" {\n\t\tt.previewMu.Lock()\n\t\tch, ok := t.previewRequests[ack.RefID]\n\t\tif ok {\n\t\t\tdelete(t.previewRequests, ack.RefID)\n\t\t}\n\t\tt.previewMu.Unlock()\n\t\tif ok {\n\t\t\tch <- ack.PreviewHandle\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (t *gatewayTransport) waitPreviewAck(refID string, timeout time.Duration) (string, error) {\n\tch := make(chan string, 1)","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/cloud-web/gateway.go#L267-L303","documentation":"The gateway transport POSTed an outbound message to the cloud-web server's send endpoint and the server replied with HTTP status >= 300. The error includes the status code and up to 1MB of the response body for diagnosis. This means the message was not accepted by the server.","triggerScenarios":"Send() receives a response with status 3xx/4xx/5xx: 401 on token mismatch, 404 on wrong send_path or base_url path prefix, 413 on oversized payloads, 500/502 on server or proxy failure.","commonSituations":"Rotated token not updated in cc-connect config; base_url missing a path prefix (e.g. behind /api) so send_path resolves to 404; reverse proxy timing out with 502/504; server bug returning 500.","solutions":["Inspect the status/body in the error: 401 -> fix the token; 404 -> fix base_url/send_path; 5xx -> check server logs.","Verify the token in config.toml matches the cloud-web server's shared secret.","Confirm base_url + send_path form the correct full endpoint URL (curl -H \"Authorization: Bearer $TOKEN\" the endpoint).","Retry after fixing; transient 502/504 usually means the server or its proxy was briefly unavailable."],"exampleFix":"// config.toml — before\nbase_url = \"https://cloud.example.com\"  # server mounts API under /api -> 404\n\n// after\nbase_url = \"https://cloud.example.com/api\"","handlingStrategy":"try-catch","validationCode":"// verify send endpoint + auth before going live\nreq, _ := http.NewRequest(\"POST\", sendURL, bytes.NewReader([]byte(\"{}\")))\nreq.Header.Set(\"Authorization\", \"Bearer \"+token)\nresp, err := http.DefaultClient.Do(req)\nif err != nil {\n    return err\n}\nresp.Body.Close()\nif resp.StatusCode >= 300 {\n    return fmt.Errorf(\"send endpoint returned %d; fix base_url/send_path/token\", resp.StatusCode)\n}","typeGuard":null,"tryCatchPattern":"if err := platform.Send(ctx, msg); err != nil {\n    var retriable bool\n    if strings.Contains(err.Error(), \"send HTTP 5\") || strings.Contains(err.Error(), \"send HTTP 429\") {\n        retriable = true\n    }\n    slog.Error(\"cloud-web send failed\", \"error\", err, \"retriable\", retriable)\n    if retriable {\n        time.Sleep(time.Second)\n        return platform.Send(ctx, msg)\n    }\n    return err\n}","preventionTips":["Match token, base_url, and send_path against server config after every deploy","Differentiate retry policy by status class (5xx/429 retriable, 401/404 not)","Add alerts on repeated send failures","Test the endpoint with curl when in doubt"],"tags":["http","api-error","cloud-web"],"backgroundTag":"api-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}