Skip to content

Fix: validate HTTP status before treating response as pull secret - #1032

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
cjnovak98:fix-pull-secret-status-check
Nov 19, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
cjnovak98:fix-pull-secret-status-check

Conversation

@cjnovak98

@cjnovak98 cjnovak98 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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.

What type of PR is this?

  • fix (Bug Fix)
  • feat (New Feature)
  • docs (Documentation)
  • test (Test Coverage)
  • chore (Clean Up / Maintenance Tasks)
  • other (Anything that doesn't fit the above)

What this PR does / Why we need it?

Which Jira/Github issue(s) does this PR fix?

  • Related Issue #
  • Closes #

Special notes for your reviewer

Unit Test Coverage

Guidelines

  • If it's a new sub-command or new function to an existing sub-command, please cover at least 50% of the code
  • If it's a bug fix for an existing sub-command, please cover 70% of the code

Test coverage checks

  • Added unit tests
  • Created jira card to add unit test
  • This PR may not need unit tests

Pre-checks (if applicable)

  • Ran unit tests locally
  • Validated the changes in a cluster
  • Included documentation changes with PR
  • Backward compatible

/label tide/merge-method-squash

Summary by CodeRabbit

  • Bug Fixes
    • Pull-secret requests now report an error when the service returns a non-successful response, including the response’s status code and details. This makes failed requests easier to identify and understand.

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 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Walkthrough

GetPullSecret now checks for an HTTP 200 response. For other status codes, it returns an error that includes the status code and response body.

Changes

Pull-secret response handling

Layer / File(s) Summary
Validate pull-secret response status
pkg/ocm/ocm.go
GetPullSecret returns an error with the response status and body when the status is not 200.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: Minimal · up to e6af1

Pull-secret fetches now fail with a clear error when the server returns a non-200 status, so error responses are no longer cached as credentials. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Fix: validate HTTP status before treating response as pull secret" matches the changeset. The raw summary says GetPullSecret now rejects non-200 responses with an error that includes the st…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Fix: validate HTTP status before treating response as pull secret" matches the changeset. The raw summary says GetPullSecret now rejects non-200 responses with an error that includes the status code and body, and the PR objectives state the same goal. The title names the main change, so it passes. Minor note: the title is 65 characters, which is within a normal length for a commit subject.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 447c6b7 and e6af195.

Files selected for processing: 1

  • pkg/ocm/ocm.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@openshift-ci
openshift-ci Bot requested review from Tafhim and geowa4 November 19, 2026 17:59
@openshift-ci

openshift-ci Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@cjnovak98: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.58%. Comparing base (447c6b7) to head (e6af195).

Files with missing lines Patch % Lines
pkg/ocm/ocm.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1032      +/-   ##
==========================================
- Coverage   56.63%   56.58%   -0.06%     
==========================================
  Files          78       78              
  Lines        6191     6193       +2     
==========================================
- Hits         3506     3504       -2     
- Misses       2280     2283       +3     
- Partials      405      406       +1     
Files with missing lines Coverage Δ
pkg/ocm/ocm.go 4.10% <0.00%> (-0.03%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@geowa4

geowa4 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Nov 19, 2026
@openshift-ci

openshift-ci Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: geowa4

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 19, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit f82de74 into openshift:main Nov 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants