{"record":{"id":"e54d542ad1ec2329","repo":"chenhg5/cc-connect","slug":"cloud-web-register-http-d-s","errorCode":null,"errorMessage":"cloud_web: register HTTP %d: %s","messagePattern":"cloud_web: register HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/cloud-web/gateway.go","lineNumber":154,"sourceCode":"\t\treturn nil, err\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, t.registerURL, bytes.NewReader(body))\n\tif err != nil {\n\t\treturn nil, 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 nil, err\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\traw, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"cloud_web: register HTTP %d: %s\", resp.StatusCode, string(raw))\n\t}\n\treturn parseRegisterAck(raw)\n}\n\nfunc (t *gatewayTransport) authenticate(r *http.Request) bool {\n\tif t.token == \"\" {\n\t\t// Fail closed: a gateway transport without a configured token must\n\t\t// reject all inbound webhooks rather than accept anything. New()\n\t\t// already enforces a non-empty token; this is a defense-in-depth guard.\n\t\treturn false\n\t}\n\tif auth := r.Header.Get(\"Authorization\"); strings.HasPrefix(auth, \"Bearer \") {\n\t\treturn subtle.ConstantTimeCompare([]byte(auth[7:]), []byte(t.token)) == 1\n\t}\n\tif tok := r.Header.Get(\"X-Cloud-Web-Token\"); tok != \"\" {\n\t\treturn subtle.ConstantTimeCompare([]byte(tok), []byte(t.token)) == 1\n\t}\n\tif tok := r.URL.Query().Get(\"token\"); tok != \"\" {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/cloud-web/gateway.go#L136-L172","documentation":"The gateway transport's register call to the cloud-web server returned a non-200 HTTP status. The transport POSTs a registration payload (name, project, public_url) to register_url to exchange capabilities; any non-OK response is surfaced with the status code and the first up-to-1MB of the response body. Note Start() only logs this as a warning — the gateway still runs with default capabilities.","triggerScenarios":"POST to the configured register_url returns 401 (bad/missing token), 404 (wrong register_url path), 500 (server error), etc. — anything other than HTTP 200 is treated as failure.","commonSituations":"Token mismatch between cc-connect and the cloud-web server; register_url pointing at the wrong host/path or at the webhook URL instead of the register endpoint; server deployed behind a proxy that returns 404/502; server-side auth rotation after a token change.","solutions":["Read the status and body in the error: 401/403 means fix the shared token in config; 404 means fix register_url; 5xx means check the cloud-web server logs.","Confirm the token in config.toml matches the server's expected bearer token exactly.","Point register_url at the server's register endpoint (e.g. https://host/register), not the webhook or send path.","If the server was down, redeploy it and restart cc-connect; remember Start continues with default capabilities so capabilities may be wrong until restart."],"exampleFix":"// config.toml — before\nregister_url = \"https://cloud.example.com/webhook\"  # wrong endpoint, 404\n\n// after\nregister_url = \"https://cloud.example.com/register\"","handlingStrategy":"try-catch","validationCode":"// smoke-test register before Start\nresp, err := http.Post(registerURL, \"application/json\", bytes.NewReader([]byte(\"{}\")))\nif err != nil || resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"register endpoint not healthy (status %d)\", resp.StatusCode)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := platform.Start(ctx, handler); err != nil {\n    var httpErr interface{ Error() string }\n    if errors.As(err, &httpErr) && strings.Contains(err.Error(), \"register HTTP\") {\n        slog.Warn(\"gateway register rejected; running with default capabilities\", \"error\", err)\n    }\n    return err\n}","preventionTips":["Keep the shared token identical on server and client config","Point register_url at the register endpoint, not webhook or send paths","Monitor for the 'gateway register failed' warning at startup — capabilities may be degraded","Smoke-test the register endpoint with curl after any server redeploy"],"tags":["http","registration","authentication","cloud-web"],"backgroundTag":"http-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}