From e6af1955f4ed0342b478b877d9357ad4e9a054c6 Mon Sep 17 00:00:00 2001 From: cjnovak98 Date: Thu, 19 Nov 2026 12:56:57 -0500 Subject: [PATCH] Fix: validate HTTP status before treating response as pull secret GetPullSecret() posts to /api/accounts_mgmt/v1/access_token and treats the response body as the pull secret unconditionally. The ocm-sdk-go Send() call only returns an error on transport failure; any HTTP status (401, 403, 503, etc.) is returned as a normal response per the SDK's own doc comment. On a non-200 response, the error JSON body was being written to ~/.kube/ocm-pull-secret/config.json as if it were a valid podman/docker authfile. Because fetchPullSecretIfNotExist() only re-fetches when that file is absent, a single transient failure (or an account lacking the required entitlement) permanently poisons the cached authfile. Every subsequent `ocm backplane console` pull then fails with a generic "access denied" from podman, with no indication the real cause was an OCM-side error. This adds a status check so a non-200 response surfaces as an error instead of being cached as a broken credential. Co-Authored-By: Claude Sonnet 5 --- pkg/ocm/ocm.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/ocm/ocm.go b/pkg/ocm/ocm.go index 27300b02..40b82703 100644 --- a/pkg/ocm/ocm.go +++ b/pkg/ocm/ocm.go @@ -337,6 +337,9 @@ func (o *DefaultOCMInterfaceImpl) GetPullSecret() (string, error) { if err != nil { return "", fmt.Errorf("failed to get pull secret from ocm: %v", err) } + if response.Status() != http.StatusOK { + return "", fmt.Errorf("failed to get pull secret from ocm: status %d: %s", response.Status(), response.String()) + } logger.Debugln("Found pull secret from ocm") pullSecret := response.String()