Skip to content

FCN-247: regions api call#6490

Open
davidaznaur wants to merge 12 commits into
stolostron:mainfrom
davidaznaur:FCN-247-regions-api
Open

FCN-247: regions api call#6490
davidaznaur wants to merge 12 commits into
stolostron:mainfrom
davidaznaur:FCN-247-regions-api

Conversation

@davidaznaur

@davidaznaur davidaznaur commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):
Regions api call for the ROSA HCP wizard

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 a ROSA wizard API endpoint (POST /regions) and corresponding client helper to fetch available cloud provider regions.
    • Region dropdown now supports only AWS regions that enable hypershift/hosted control planes, with secret-dependent loading and error states.
  • Bug Fixes

    • Improved backend request handling with explicit error trapping and consistent internal error responses for existing ROSA wizard flows.
  • Tests

    • Added backend tests for POST /regions, plus frontend tests for query keys, region filtering/formatting, hook behavior, and API request wiring.

@openshift-ci

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: davidaznaur
Once this PR has been reviewed and has the lgtm label, please assign rawagner for approval. 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

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/cc @KevinFCormier

@openshift-ci
openshift-ci Bot requested a review from KevinFCormier July 16, 2026 13:58
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@davidaznaur, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 89e2c09d-40ef-4577-a01f-d2f64688c348

📥 Commits

Reviewing files that changed from the base of the PR and between ea33443 and ffe0c9c.

📒 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/useFetchRegions.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.ts
  • frontend/webpack.config.ts
📝 Walkthrough

Walkthrough

The PR adds a backend POST /regions endpoint that retrieves OCM cloud providers with regions, plus frontend types, API access, query caching, and a hook that returns hypershift-capable AWS regions as dropdown options.

Changes

ROSA wizard regions

Layer / File(s) Summary
Backend regions API
backend/src/app.ts, backend/src/routes/rosaWizardApi.ts, backend/test/routes/rosaWizardApi.test.ts
Registers POST /regions, retrieves OCM cloud providers with regions using service-account credentials, handles failures, and tests success, upstream errors, and authentication failures. Existing AWS handlers also gain inner request-body error handling.
Frontend region contract and API wiring
frontend/src/resources/rosa-hcp-wizard.ts, frontend/src/lib/rosa-hcp-api.ts, frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.ts, frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.test.ts, frontend/webpack.config.ts, frontend/src/lib/rosa-hcp-api.test.ts
Adds provider and region interfaces, the /regions API wrapper, a regions query key, proxy configuration, and API/query-key tests.
Region query and formatting
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/constants/types.ts, frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.ts, frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.test.tsx
Adds useFetchRegions, filters AWS regions with supports_hypershift === true, maps them to { value, label } dropdown options, controls query enablement, and tests query state and edge cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Wizard
  participant Backend
  participant OCM
  Wizard->>Backend: POST /regions with service account credentials
  Backend->>OCM: Authenticate and obtain service token
  Backend->>OCM: Fetch cloud providers with regions
  OCM-->>Backend: Return provider and region data
  Backend-->>Wizard: Return JSON response
  Wizard->>Wizard: Select AWS hypershift regions
Loading

Possibly related PRs

  • stolostron/console#6470: Modifies the existing ROSA wizard handlers and overlaps with the request-body error-handling changes.
🚥 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 is concise and clearly summarizes the main change: adding a regions API call for the ROSA HCP wizard.
Description check ✅ Passed The description follows the template with summary, ticket link, type, checklist, and notes, and it is sufficiently complete.
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.

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/cc @vishsanghishetty

@openshift-ci
openshift-ci Bot requested a review from vishsanghishetty July 16, 2026 13:58

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

🧹 Nitpick comments (2)
frontend/src/lib/rosa-hcp-api.ts (1)

73-85: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use camelCase for function parameters.

As per coding guidelines, functions and variables must use descriptive camelCase names. Please rename client_id and client_secret to clientId and clientSecret.

♻️ Proposed refactor
 export const getWizardRegions = (
-  client_id: string,
-  client_secret: string,
+  clientId: string,
+  clientSecret: string,
   signal?: AbortSignal,
   additionalData?: Record<string, unknown>
 ): Promise<CloudProviderResponse> =>
   getWizardData<CloudProviderResponse, Record<string, unknown>>(
-    client_id,
-    client_secret,
+    clientId,
+    clientSecret,
     '/regions',
     signal,
     additionalData
   )
🤖 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 73 - 85, Rename the
getWizardRegions parameters client_id and client_secret to clientId and
clientSecret, and update their corresponding references in the getWizardData
call while preserving the existing API behavior.

Source: Coding guidelines

frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/constants/types.ts (1)

7-10: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use interface for object shapes.

As per coding guidelines, use interface for object shapes that may be extended, and type for unions and computed types.

♻️ Proposed refactor
-export type DropdownType = {
+export interface DropdownType {
   value: string
   label: string
 }
🤖 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/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/constants/types.ts`
around lines 7 - 10, Replace the DropdownType object-shape alias with an
interface named DropdownType, preserving its existing value and label string
properties.

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 100-128: Update getWizardCloudProviders, getAwsAccountIds, and
getAwsBillingAccountIds to explicitly return Promise<void>, join request-body
chunks with an empty separator, and wrap each async req.on('end') callback body
in try/catch so JSON parsing or token-fetch failures log the error and send the
existing internal-server-error response instead of causing an unhandled
rejection or hanging request.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.ts`:
- Around line 12-17: Filter regions in the useFetchRegions query so entries
without an ID are excluded before mapping, while retaining the existing
Hypershift support condition. Update
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.ts
at lines 12-17 accordingly, and revise
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.test.tsx
at lines 202-225 to assert that an ID-less region produces an empty result
rather than a fallback option.

---

Nitpick comments:
In `@frontend/src/lib/rosa-hcp-api.ts`:
- Around line 73-85: Rename the getWizardRegions parameters client_id and
client_secret to clientId and clientSecret, and update their corresponding
references in the getWizardData call while preserving the existing API behavior.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/constants/types.ts`:
- Around line 7-10: Replace the DropdownType object-shape alias with an
interface named DropdownType, preserving its existing value and label string
properties.
🪄 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: 179f794b-de4b-4592-87a3-578d28e51fdf

📥 Commits

Reviewing files that changed from the base of the PR and between 79aa736 and c1bf55e.

📒 Files selected for processing (10)
  • backend/src/app.ts
  • backend/src/routes/rosaWizardApi.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/useFetchRegions.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchRegions.ts
  • frontend/webpack.config.ts

Comment thread backend/src/routes/rosaWizardApi.ts Outdated
Comment thread backend/src/routes/rosaWizardApi.ts
Comment thread backend/src/routes/rosaWizardApi.ts Outdated

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/src/routes/rosaWizardApi.ts (1)

1-1: 🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win

Use an empty string separator to join request body chunks.

By default, chucks.join() uses a comma as the separator, which will corrupt multi-chunk JSON payloads before JSON.parse is executed. As highlighted in a previous review, this must be explicitly joined with an empty string.

  • backend/src/routes/rosaWizardApi.ts#L41-41: Change to data = chucks.join('') in getAwsAccountIds.
  • backend/src/routes/rosaWizardApi.ts#L82-82: Change to data = chucks.join('') in getAwsBillingAccountIds.
  • backend/src/routes/rosaWizardApi.ts#L122-122: Change to data = chucks.join('') in getWizardCloudProviders.
🤖 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` at line 1, Update the request-body
assembly in getAwsAccountIds, getAwsBillingAccountIds, and
getWizardCloudProviders to join chunks with an empty string explicitly,
preserving the JSON payload before JSON.parse.
🤖 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`:
- Line 122: Update the request-body assembly in the visible data assignment to
join the chucks array with an empty string separator, preserving multi-chunk
JSON before parsing.
- Line 82: Update the request-body assembly in the surrounding handler to join
the chucks array with an empty separator, preserving the original JSON across
multiple chunks before parsing.
- Line 41: Update the request-body chunk assembly at the data assignment to join
the chucks array with an empty string separator, preserving the original JSON
payload across multiple chunks before parsing.

---

Outside diff comments:
In `@backend/src/routes/rosaWizardApi.ts`:
- Line 1: Update the request-body assembly in getAwsAccountIds,
getAwsBillingAccountIds, and getWizardCloudProviders to join chunks with an
empty string explicitly, preserving the JSON payload before JSON.parse.
🪄 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: c40522a9-05b5-4de2-ab1d-f0efa1ccbca9

📥 Commits

Reviewing files that changed from the base of the PR and between c1bf55e and ea33443.

📒 Files selected for processing (3)
  • backend/src/routes/rosaWizardApi.ts
  • backend/test/routes/rosaWizardApi.test.ts
  • frontend/src/lib/rosa-hcp-api.test.ts

Comment thread backend/src/routes/rosaWizardApi.ts Outdated
Comment thread backend/src/routes/rosaWizardApi.ts Outdated
Comment thread backend/src/routes/rosaWizardApi.ts Outdated
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/test unit-tests-sonarcloud

1 similar comment
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/test unit-tests-sonarcloud

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/test unit-tests-sonarcloud

@coderabbitai coderabbitai Bot mentioned this pull request Jul 21, 2026
18 tasks
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/test unit-tests-sonarcloud

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>
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>
Signed-off-by: David Aznaurov <daznauro@redhat.com>
Signed-off-by: David Aznaurov <daznauro@redhat.com>
@davidaznaur
davidaznaur force-pushed the FCN-247-regions-api branch from 6e3aa4f to ffe0c9c Compare July 21, 2026 17:14
@sonarqubecloud

Copy link
Copy Markdown

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/retest

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