Skip to content

FCN-254: role arns api call#6498

Open
davidaznaur wants to merge 10 commits into
stolostron:mainfrom
davidaznaur:FCN-254-roles-api-call
Open

FCN-254: role arns api call#6498
davidaznaur wants to merge 10 commits into
stolostron:mainfrom
davidaznaur:FCN-254-roles-api-call

Conversation

@davidaznaur

@davidaznaur davidaznaur commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):
Account, OCM and User role ARNs api calls

Ticket Link:

Type of Change:

  • 🐞 Bug Fix
  • ✨ Feature
  • 🔧 Refactor
  • 💸 Tech Debt
  • 🧪 Test-related
  • 📄 Docs

✅ Checklist

General

  • PR title follows the convention (e.g. ACM-12340 Fix bug with...)
  • Code builds and runs locally without errors
  • No console logs, commented-out code, or unnecessary files
  • All commits are meaningful and well-labeled
  • [] All new display strings are externalized for localization (English only)
  • (Nice to have) JSDoc comments added for new functions and interfaces

If Feature

  • UI/UX reviewed (if applicable)
  • All acceptance criteria met
  • Unit test coverage added or updated
  • Relevant documentation or comments included

If Bugfix

  • Root cause and fix summary are documented in the ticket (for future reference / errata)
  • Fix tested thoroughly and resolves the issue
  • Test(s) added to prevent regression

🗒️ Notes for Reviewers

Summary by CodeRabbit

  • New Features
    • Added ROSA/HCP wizard support to fetch AWS role ARNs, OCM role details, and the STS user role.
    • Introduced new backend POST endpoints and matching frontend proxy routes for /sts-role-arns, /sts-ocm-role, and /sts-user-role.
  • Bug Fixes
    • Improved request JSON reconstruction for AWS role lookups.
    • Enhanced role fetching error handling, including friendly “user role not found” messaging.
  • Tests
    • Expanded coverage for the new routes and the roles-fetching hook, including auth failures.
  • Refactor
    • Updated frontend wizard API helpers and role normalization/types to support the new data flow.

Signed-off-by: David Aznaurov <daznauro@redhat.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The ROSA Wizard adds authenticated STS role endpoints, frontend API helpers and response types, query-key support, proxy paths, and a React Query hook that normalizes role ARNs and exposes combined role data and status.

Changes

ROSA Wizard STS integration

Layer / File(s) Summary
Backend STS routes
backend/src/app.ts, backend/src/routes/rosaWizardApi.ts, backend/test/routes/rosaWizardApi.test.ts
Registers three authenticated POST routes for account roles, the OCM role, and the user role. Backend request-body assembly concatenates chunks without separators, with success, error, and authentication tests.
Frontend API contracts and transport
frontend/src/resources/rosa-hcp-wizard.ts, frontend/src/lib/rosa-hcp-api.ts, frontend/src/lib/rosa-hcp-api.test.ts, frontend/src/routes/Infrastructure/.../queries/queryKeyFactory.ts, frontend/src/routes/Infrastructure/.../queries/queryKeyFactory.test.ts, frontend/webpack.config.ts
Adds role response and AWS account payload types, updates STS API helpers and query keys, tests request construction, and proxies the new backend paths.
Role normalization and wizard mapping
frontend/src/routes/Infrastructure/.../constants/types.ts, frontend/src/routes/Infrastructure/.../queries/useFetchRolesARNs.ts, frontend/src/routes/Infrastructure/.../queries/useFetchRolesARNs.test.tsx
Splits account-role ARNs by policy set, normalizes role fields, and maps normalized entries into wizard role options with normalization coverage.
Role query orchestration
frontend/src/routes/Infrastructure/.../queries/useFetchRolesARNs.ts, frontend/src/routes/Infrastructure/.../queries/useFetchRolesARNs.test.tsx
Coordinates gated queries for account roles, OCM roles, and user roles, exposing combined results, loading state, derived errors, and fetch/refetch callbacks with query-state coverage.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ROSAWizardClient
  participant useFetchRoleARNs
  participant rosa-hcp-api
  participant rosaWizardApi
  participant OCM
  ROSAWizardClient->>useFetchRoleARNs: fetch(accountId)
  useFetchRoleARNs->>rosa-hcp-api: Request three role resources
  rosa-hcp-api->>rosaWizardApi: POST STS role endpoints
  rosaWizardApi->>OCM: Authenticate and query role APIs
  OCM-->>rosaWizardApi: Return role responses
  rosaWizardApi-->>rosa-hcp-api: Return JSON data
  rosa-hcp-api-->>useFetchRoleARNs: Provide query results
  useFetchRoleARNs-->>ROSAWizardClient: Return normalized roles and status
Loading

Possibly related PRs

  • stolostron/console#6470: Extends the same ROSA Wizard routing and modifies AWS account request-body chunk reassembly.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title names the FCN-254 role ARN API call change and matches the main scope of the PR.
Description check ✅ Passed The description covers summary, ticket link, type, and checklist sections from the template, with only minor unchecked items.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Signed-off-by: David Aznaurov <daznauro@redhat.com>
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/cc @kelvah

@openshift-ci
openshift-ci Bot requested a review from kelvah July 17, 2026 13:27
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/cc @KevinFCormier

@openshift-ci
openshift-ci Bot requested a review from KevinFCormier July 17, 2026 13:27
Comment thread backend/src/routes/rosaWizardApi.ts Outdated
Comment thread backend/src/routes/rosaWizardApi.ts Outdated
Comment thread frontend/src/lib/rosa-hcp-api.ts Outdated
Signed-off-by: David Aznaurov <daznauro@redhat.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
backend/src/routes/rosaWizardApi.ts (1)

105-183: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate handler logic between getRoleARNs and getOCMRoleARN.

Both functions share the same auth/body-parsing/token/POST/response scaffolding, differing only in accountPath. Consider extracting a shared helper (e.g. postStsInquiry(req, res, path)) to reduce duplication for this and any future STS inquiry endpoint.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/routes/rosaWizardApi.ts` around lines 105 - 183, The handlers
getRoleARNs and getOCMRoleARN duplicate the same request-processing flow.
Extract their shared authentication, body parsing, service-token retrieval,
POST, error handling, and response logic into a helper such as
postStsInquiry(req, res, accountPath), then have each handler call it with only
its distinct sts_account_roles or sts_ocm_role endpoint path.
frontend/src/lib/rosa-hcp-api.ts (1)

3-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Type-only imports should use import type across the new STS role files. Same root cause in all three: named imports of pure TypeScript interfaces/types used only as annotations, never as runtime values.

  • frontend/src/lib/rosa-hcp-api.ts#L3-L12: change import { ... } from '~/resources' to import type { ... } from '~/resources'.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.ts#L5-L6: change both ~/resources and ../constants/types imports to import type.
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.test.tsx#L5-L5: change import { SelectedSecret } from '../constants/types' to import type { SelectedSecret } from '../constants/types'.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/lib/rosa-hcp-api.ts` around lines 3 - 12, Convert the type-only
imports to `import type` in frontend/src/lib/rosa-hcp-api.ts lines 3-12, both
`~/resources` and `../constants/types` imports in
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.ts
lines 5-6, and the `SelectedSecret` import in
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.test.tsx
line 5; no other changes are needed.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/routes/rosaWizardApi.ts`:
- Around line 127-132: Update the account lookup error handling in both
getRoleARNs and getOCMRoleARN to match getUserRole: when jsonPost rejects, log
the error, call respondInternalServerError, and return immediately. Do not
continue to set headers or serialize the undefined result; preserve the existing
successful response flow.

In `@frontend/src/lib/rosa-hcp-api.ts`:
- Around line 62-76: Update getWizardRoleARNs and getWizardOCMRoleARN to unwrap
the wizard API response before returning it: return res.data.body when present,
falling back to res.data otherwise. Preserve the existing generic types and
request parameters while ensuring consumers receive the payload with items or
role fields at the top level.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.ts`:
- Line 140: Update the isLoading value in the roles ARN query result to also
include userRoleQuery.isLoading, alongside rolesQuery.isLoading and
ocmRoleQuery.isLoading, so it remains true while any of the three queries is
fetching.

---

Nitpick comments:
In `@backend/src/routes/rosaWizardApi.ts`:
- Around line 105-183: The handlers getRoleARNs and getOCMRoleARN duplicate the
same request-processing flow. Extract their shared authentication, body parsing,
service-token retrieval, POST, error handling, and response logic into a helper
such as postStsInquiry(req, res, accountPath), then have each handler call it
with only its distinct sts_account_roles or sts_ocm_role endpoint path.

In `@frontend/src/lib/rosa-hcp-api.ts`:
- Around line 3-12: Convert the type-only imports to `import type` in
frontend/src/lib/rosa-hcp-api.ts lines 3-12, both `~/resources` and
`../constants/types` imports in
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.ts
lines 5-6, and the `SelectedSecret` import in
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.test.tsx
line 5; no other changes are needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f6149555-903c-42cb-bead-dd73ef1d8408

📥 Commits

Reviewing files that changed from the base of the PR and between d149900 and 1db045c.

📒 Files selected for processing (12)
  • backend/src/app.ts
  • backend/src/routes/rosaWizardApi.ts
  • backend/test/routes/rosaWizardApi.test.ts
  • frontend/src/lib/rosa-hcp-api.test.ts
  • frontend/src/lib/rosa-hcp-api.ts
  • frontend/src/resources/rosa-hcp-wizard.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/constants/types.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.test.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRolesARNs.ts
  • frontend/webpack.config.ts

Comment thread backend/src/routes/rosaWizardApi.ts
Comment thread frontend/src/lib/rosa-hcp-api.ts
@davidaznaur
davidaznaur requested a review from kelvah July 21, 2026 14:49
Signed-off-by: David Aznaurov <daznauro@redhat.com>
Signed-off-by: David Aznaurov <daznauro@redhat.com>
Signed-off-by: David Aznaurov <daznauro@redhat.com>
Signed-off-by: David Aznaurov <daznauro@redhat.com>
Signed-off-by: David Aznaurov <daznauro@redhat.com>

@KevinFCormier KevinFCormier left a comment

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.

AI-code review generated a few more things that deserve consideration. Please take a look. Thanks.

Comment thread backend/src/routes/rosaWizardApi.ts
Signed-off-by: David Aznaurov <daznauro@redhat.com>
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot mentioned this pull request Jul 22, 2026
19 tasks
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: davidaznaur, kelvah
Once this PR has been reviewed and has the lgtm label, please ask for approval from kevinfcormier. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Signed-off-by: David Aznaurov <daznauro@redhat.com>
@openshift-ci openshift-ci Bot removed the lgtm label Jul 22, 2026
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

@davidaznaur: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/unit-tests-sonarcloud ee06afd link true /test unit-tests-sonarcloud

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants