{"record":{"id":"4ce053bbc8d901b9","repo":"vitessio/vitess","slug":"err-error-enablerecovery-failure","errorCode":null,"errorMessage":"err.Error() (EnableRecovery failure)","messagePattern":"err\\.Error\\(\\) \\(EnableRecovery failure\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"go/vt/vtorc/server/api.go","lineNumber":253,"sourceCode":"\t}\n\treturnAsJSON(response, http.StatusOK, results)\n}\n\n// disableGlobalRecoveriesAPIHandler is the handler for the disableGlobalRecoveriesAPI endpoint\nfunc disableGlobalRecoveriesAPIHandler(response http.ResponseWriter) {\n\terr := logic.DisableRecovery()\n\tif err != nil {\n\t\thttp.Error(response, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\twritePlainTextResponse(response, \"Global recoveries disabled\", http.StatusOK)\n}\n\n// enableGlobalRecoveriesAPIHandler is the handler for the enableGlobalRecoveriesAPI endpoint\nfunc enableGlobalRecoveriesAPIHandler(response http.ResponseWriter) {\n\terr := logic.EnableRecovery()\n\tif err != nil {\n\t\thttp.Error(response, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\twritePlainTextResponse(response, \"Global recoveries enabled\", http.StatusOK)\n}\n\n// LegacyDetectionAnalysisJSON is a wrapper to *inst.DetectionAnalysis that\n// provides the AnalyzedInstanceAlias field in the old string-based format.\ntype LegacyDetectionAnalysisJSON struct {\n\t*inst.DetectionAnalysis\n}\n\n// NewLegacyDetectionAnalysisJSON wraps a *inst.DetectionAnalysis with *LegacyDetectionAnalysisJSON.\nfunc NewLegacyDetectionAnalysisJSON(da *inst.DetectionAnalysis) *LegacyDetectionAnalysisJSON {\n\treturn &LegacyDetectionAnalysisJSON{da}\n}\n\n// MarshalJSON converts a *LegacyDetectionAnalysisJSON to the legacy format JSON,\n// outputting AnalyzedInstanceAlias and AnalyzedInstancePrimaryAlias as strings.","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtorc/server/api.go#L235-L271","documentation":"This is the HTTP 500 body produced by the vtorc /enable-global-recoveries API handler when logic.EnableRecovery() returns an error. VTOrc refuses to re-enable global recovery processing because an underlying step (e.g. writing orchestrator settings/leadership state) failed. The raw error text is forwarded verbatim so the caller can see the cause.","triggerScenarios":"POST/GET to the vtorc /enable-global-recoveries endpoint while EnableRecovery fails — typically because the backend it writes recovery-enablement state to (the orchestrator backing store / topo) is unavailable or rejects the write.","commonSituations":"VTOrc's backing store or topology server is down or misconfigured; permissions prevent writing the recovery-enabled flag; running the endpoint against a vtorc instance that lost its backend connection.","solutions":["Check the vtorc logs for the full EnableRecovery error to identify the failing backend call","Verify vtorc's topology/topo connectivity and credentials, then retry the endpoint","Confirm the vtorc instance is healthy (/health) and that its backing storage is reachable before retrying"],"exampleFix":"// before: raw 500 with err.Error()\nhttp.Error(response, err.Error(), http.StatusInternalServerError)\n// after: log and return a wrapped, actionable message\nlog.Error(\"EnableRecovery failed\", slog.Any(\"error\", err))\nhttp.Error(response, fmt.Sprintf(\"failed to enable global recoveries: %v\", err), http.StatusInternalServerError)","handlingStrategy":"try-catch","validationCode":"resp, err := http.Get(vtorcURL + \"/health\")\nif err != nil || resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"vtorc unhealthy, skipping enable-global-recoveries\")\n}","typeGuard":null,"tryCatchPattern":"resp, err := http.Post(vtorcURL+\"/enable-global-recoveries\", \"\", nil)\nif err != nil {\n    return err\n}\nif resp.StatusCode != http.StatusOK {\n    body, _ := io.ReadAll(resp.Body)\n    return fmt.Errorf(\"enable global recoveries failed (%d): %s\", resp.StatusCode, body)\n}","preventionTips":["Check vtorc /health before calling admin endpoints","Monitor vtorc-to-topo connectivity","Alert on non-200 responses from recovery control endpoints"],"tags":["http-api","vtorc","recovery"],"backgroundTag":"http-500-handler-error","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}