Skip to content

fix: remove duplicated error message for cloud console#915

Open
feichashao wants to merge 1 commit intoopenshift:mainfrom
feichashao:cloud-console-debug
Open

fix: remove duplicated error message for cloud console#915
feichashao wants to merge 1 commit intoopenshift:mainfrom
feichashao:cloud-console-debug

Conversation

@feichashao
Copy link
Copy Markdown
Contributor

@feichashao feichashao commented Mar 31, 2026

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?

The backplane cloud console error message is duplicated, removing the formatted one and keep the raw response.

Before:

ERRO[0008] failed to get cloud console for cluster xxxxxxx: failed to assume role with isolated backplane flow: failed to fetch arn sequence: error from backplane: 
 Status Code: 403
 Message: no pending or approved access request:
consider running the following command to create one:
ocm-backplane accessrequest create (response body: {"statusCode":403,"message":"no pending or approved access request:\nconsider running the following command to create one:\nocm-backplane accessrequest create"})

After:

./ocm-backplane cloud console xxxxxx
ERRO[0010] failed to get cloud console for cluster xxxxxxx: failed to assume role with isolated backplane flow: failed to fetch arn sequence:
Status: 403 Forbidden
Response body: {"statusCode":403,"message":"no pending or approved access request:\nconsider running the following command to create one:\nocm-backplane accessrequest create"} 

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

@openshift-ci openshift-ci bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Mar 31, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c45f833-5dd0-42f0-835e-bf38e769fb94

📥 Commits

Reviewing files that changed from the base of the PR and between 59c1c29 and 1cd7c3b.

📒 Files selected for processing (2)
  • cmd/ocm-backplane/cloud/common.go
  • cmd/ocm-backplane/cloud/common_test.go

Walkthrough

Simplified error handling in QueryConfig.getIsolatedCredentials for non-200 responses from GetAssumeRoleSequence. Removed response body restoration and API error parsing, replacing with basic formatted error message containing status and trimmed body. Updated test assertion to match new format.

Changes

Cohort / File(s) Summary
Error handling simplification
cmd/ocm-backplane/cloud/common.go, cmd/ocm-backplane/cloud/common_test.go
Changed non-200 error handling to remove response body restoration and utils.TryPrintAPIError call, returning simplified error with only response.Status and trimmed body. Updated test assertion from "response body:" to "Response body:" (capitalization).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci bot requested review from a7vicky and xiaoyu74 March 31, 2026 03:54
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 31, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feichashao

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 Mar 31, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 31, 2026

@feichashao: 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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.91%. Comparing base (59c1c29) to head (1cd7c3b).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #915      +/-   ##
==========================================
- Coverage   53.93%   53.91%   -0.02%     
==========================================
  Files          88       88              
  Lines        6656     6651       -5     
==========================================
- Hits         3590     3586       -4     
+ Misses       2596     2595       -1     
  Partials      470      470              
Files with missing lines Coverage Δ
cmd/ocm-backplane/cloud/common.go 55.83% <100.00%> (-0.38%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if readErr == nil {
response.Body = io.NopCloser(strings.NewReader(bodyStr))
}
apiErr := utils.TryPrintAPIError(response, false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks removing TryPrintAPIError here makes this path inconsistent with the rest of the CLI as I can see most other cli commands rely on TryPrintAPIError as the standard way to parse and present bp-api errors.

IIUC, the original intent (from PR #825) was to improve visibility for non-JSON responses (e.g. infra errors like 502), which is a valid. However, removing TryPrintAPIError means we lose the structured/clean formatting for the common case (JSON errors from bp-api).

Would it make sense to keep TryPrintAPIError for JSON responses, and only fall back to raw response body when parsing fails (non-JSON)? WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. I will make a card for this instead as it requires some efforts to carefully change and test.

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. 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