{"record":{"id":"733587ec930a7430","repo":"kubernetes/kops","slug":"error-applying-endpoint-v","errorCode":null,"errorMessage":"Error applying endpoint: %v","messagePattern":"Error applying endpoint: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"discovery/pkg/discovery/server.go","lineNumber":219,"sourceCode":"\t}\n\n\t// Validation: ensure the name in body matches the URL\n\tif input.ObjectMeta.Name != name {\n\t\tlog.Info(\"Forbidden: name does not match\", \"name\", input.ObjectMeta.Name, \"expected\", name)\n\t\thttp.Error(w, \"Forbidden: name does not match\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\t// Validation: ensure the namespace in body matches the URL\n\tif input.ObjectMeta.Namespace != ns {\n\t\tlog.Info(\"Forbidden: namespace does not match\", \"namespace\", input.ObjectMeta.Namespace, \"expected\", ns)\n\t\thttp.Error(w, \"Forbidden: namespace does not match\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tif err := s.Store.UpsertDiscoveryEndpoint(r.Context(), universeID, &input); err != nil {\n\t\tlog.Error(err, \"error applying endpoint\")\n\t\thttp.Error(w, fmt.Sprintf(\"Error applying endpoint: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Return the created object\n\ts.writeJSON(w, http.StatusCreated, input)\n\n\tlog.Info(\"Applied endpoint\", \"namespace\", input.ObjectMeta.Namespace, \"name\", input.ObjectMeta.Name, \"universe\", universeID)\n}\n\nfunc (s *Server) handleGetDiscoveryEndpoint(w http.ResponseWriter, r *http.Request, _ *UserInfo) {\n\tuniverseID := r.PathValue(\"universe\")\n\tns := r.PathValue(\"namespace\")\n\tname := r.PathValue(\"name\")\n\n\tfound, err := s.Store.GetDiscoveryEndpoint(r.Context(), universeID, ns, name)\n\tif err != nil {\n\t\thttp.Error(w, fmt.Sprintf(\"Error getting endpoint: %v\", err), http.StatusInternalServerError)\n\t\treturn","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/discovery/pkg/discovery/server.go#L201-L237","documentation":"All client-side validation passed but Store.UpsertDiscoveryEndpoint returned an error while persisting the DiscoveryEndpoint. The server wraps the store error and returns HTTP 500 with 'Error applying endpoint: %v'; the underlying cause is whatever the store implementation reported (network, serialization, storage failure).","triggerScenarios":"Any apply request whose store write fails: store's backing database/etcd unreachable, request context cancelled mid-write, object fails backend validation/serialization, or a storage-layer conflict occurs.","commonSituations":"Store backend down or misconfigured connection string; store credentials lack write permission; transient network partition between discovery server and storage; quota/resource limits exceeded in the backing store.","solutions":["Read the %v detail in the response body and the server log line 'error applying endpoint' to identify the underlying store error","Check connectivity and credentials between the discovery server and its store backend; repair/restart the store if down","Retry the apply with backoff if the cause was transient (timeout, network blip)","Verify store configuration (endpoint, schema/migrations, permissions) before restarting the server"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-check: ensure the endpoint serializes before sending\nfunc precheck(ep *DiscoveryEndpoint) error {\n    if _, err := json.Marshal(ep); err != nil {\n        return fmt.Errorf(\"endpoint not serializable: %w\", err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"var lastErr error\nfor attempt := 0; attempt < 3; attempt++ {\n    err := client.ApplyDiscoveryEndpoint(ctx, universe, ns, name, ep)\n    if err == nil {\n        return nil\n    }\n    lastErr = err\n    var httpErr *HTTPError\n    if errors.As(err, &httpErr) && httpErr.StatusCode == http.StatusInternalServerError && strings.Contains(httpErr.Body, \"Error applying endpoint\") {\n        time.Sleep(backoff(attempt)) // transient store failure: retry with backoff\n        continue\n    }\n    return err // non-500 (e.g. 403): do not retry\n}\nreturn fmt.Errorf(\"apply failed after retries: %w\", lastErr)","preventionTips":["Monitor store backend health and alert on connectivity loss from the discovery server","Provision correct store credentials/permissions before deploying","Implement idempotent apply with exponential backoff for 500 responses","Check server logs for the 'error applying endpoint' entry to catch recurring store failures"],"tags":["http","internal-server-error","storage","persistence"],"backgroundTag":"backend-store-write-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}