Skip to content

FCN-251: oidc configs api call#6492

Open
davidaznaur wants to merge 3 commits into
stolostron:mainfrom
davidaznaur:FCN-251-oidc-configs-api
Open

FCN-251: oidc configs api call#6492
davidaznaur wants to merge 3 commits into
stolostron:mainfrom
davidaznaur:FCN-251-oidc-configs-api

Conversation

@davidaznaur

@davidaznaur davidaznaur commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):
Api call for OIDC configs for 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 HCP wizard API to retrieve OIDC configurations via POST /oidc-configs.
    • Added frontend support to fetch and present OIDC configuration options based on the selected secret and AWS account, including a new React hook and query key helper.
  • Bug Fixes
    • Improved dev/proxy routing for OIDC configuration requests (/multicloud/oidc-configs).
  • Tests
    • Added backend and frontend coverage for success paths, authentication and token failures, downstream errors, query enabling/disable behavior, option mapping, and loading/error states.

Signed-off-by: David Aznaurov <daznauro@redhat.com>
@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 yiraechristinekim 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

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 618552ad-0305-4592-a2b7-b8246c6ecc51

📥 Commits

Reviewing files that changed from the base of the PR and between f4bdd1b and 5f8064b.

📒 Files selected for processing (1)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx

📝 Walkthrough

Walkthrough

Adds authenticated backend retrieval for ROSA OIDC configurations filtered by AWS account, frontend response types and API access, and a React Query hook that maps results into selectable options with query-key and proxy support.

Changes

ROSA OIDC configuration flow

Layer / File(s) Summary
Backend OIDC endpoint
backend/src/app.ts, backend/src/routes/rosaWizardApi.ts, backend/test/routes/rosaWizardApi.test.ts
Adds POST /oidc-configs, parses aws_account_id, obtains an SSO service token, queries OpenShift OIDC configurations, and tests success and failure responses.
Frontend API contract
frontend/src/resources/rosa-hcp-wizard.ts, frontend/src/lib/rosa-hcp-api.ts, frontend/src/lib/rosa-hcp-api.test.ts
Defines the paginated OIDC response shape and adds the /oidc-configs API helper with request, abort-signal, success, and error tests.
Frontend query integration
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/*, frontend/webpack.config.ts
Adds the OIDC query key and useFetchOIDCConfigs hook, maps configurations to options, tests query behavior, and proxies /multicloud/oidc-configs.

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

Sequence Diagram(s)

sequenceDiagram
  participant Wizard
  participant useFetchOIDCConfigs
  participant getWizardOIDCConfigs
  participant Backend
  participant OpenShift
  Wizard->>useFetchOIDCConfigs: fetch AWS account configurations
  useFetchOIDCConfigs->>getWizardOIDCConfigs: request OIDC configs
  getWizardOIDCConfigs->>Backend: POST /oidc-configs
  Backend->>OpenShift: query filtered oidc_configs
  OpenShift-->>Backend: OIDC configuration response
  Backend-->>getWizardOIDCConfigs: JSON response
  getWizardOIDCConfigs-->>useFetchOIDCConfigs: response items
  useFetchOIDCConfigs-->>Wizard: selectable options
Loading
🚥 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 matches the main change: adding an OIDC configs API call for ROSA HCP.
Description check ✅ Passed The description follows the template with summary, ticket link, type, checklist, and reviewer notes.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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 @kelvah

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

Copy link
Copy Markdown
Contributor Author

/cc @KevinFCormier

@openshift-ci
openshift-ci Bot requested a review from KevinFCormier July 16, 2026 17:46

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

🧹 Nitpick comments (4)
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.ts (2)

28-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove unnecessary async modifier.

The fetch function only performs a synchronous state update. The async modifier and Promise<void> return type are unnecessary and can be removed.

♻️ Proposed refactor
-  const fetch = useCallback(async (accountId: string): Promise<void> => {
+  const fetch = useCallback((accountId: string) => {
     setAwsAccountId(accountId)
   }, [])
🤖 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/queries/useFetchOIDCConfigs.ts`
around lines 28 - 30, Update the fetch callback in useFetchOIDCConfigs to remove
the unnecessary async modifier and Promise<void> return type, leaving it as a
synchronous callback that only calls setAwsAccountId.

32-37: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Extract the fallback array to a stable constant.

Returning an inline empty array [] as a fallback creates a new reference on every render when data is undefined. This can trigger infinite loops or unnecessary re-renders in child components that depend on data. Extract it to a stable constant outside the hook.

♻️ Proposed refactor

Apply the following diff to extract the constant:

+type OIDCConfigOption = { value: string; label: string; issuer_url: string }
+const EMPTY_OIDC_CONFIGS: OIDCConfigOption[] = []
+
 export const useFetchOIDCConfigs = (selectedSecret: SelectedSecret) => {

Then, update the return statement:

   return {
-    data: data ?? [],
+    data: data ?? EMPTY_OIDC_CONFIGS,
     isFetching: isLoading,
     error: isError ? (error instanceof Error ? error.message : 'Unknown error') : null,
     fetch,
   }
🤖 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/queries/useFetchOIDCConfigs.ts`
around lines 32 - 37, Define a stable empty-array constant outside the hook in
useFetchOIDCConfigs, then replace the inline data ?? [] fallback with that
constant. Keep the existing data behavior unchanged when fetched data is
available.
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.ts (1)

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

Use camelCase for function parameters.

As per coding guidelines, functions and variables must use descriptive camelCase names. Rename aws_account_id to awsAccountId.

♻️ Proposed refactor
-  oidcConfigs: (id: string, aws_account_id: string) => [...rosaWizardKeys.all, id, aws_account_id, 'oidc-configs'],
+  oidcConfigs: (id: string, awsAccountId: string) => [...rosaWizardKeys.all, id, awsAccountId, 'oidc-configs'],
🤖 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/queries/queryKeyFactory.ts`
at line 8, Rename the oidcConfigs parameter aws_account_id to awsAccountId in
the query key factory, and update its usage in the returned key tuple while
preserving the existing key structure.

Source: Coding guidelines

frontend/src/lib/rosa-hcp-api.ts (1)

3-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use import type for type-only imports.
All three files import TypeScript types or interfaces as values; the shared root cause is the missing type keyword. As per coding guidelines, use import type for type-only imports to avoid generating runtime imports.

  • frontend/src/lib/rosa-hcp-api.ts#L3-L9: add type to the import statement (import type { AwsAccountIdsResponse... }).
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.ts#L4-L4: add type to the import statement (import type { SelectedSecret }).
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx#L4-L4: add type to the import statement (import type { SelectedSecret }).
🤖 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 - 9, Use type-only imports
for the listed symbols: update frontend/src/lib/rosa-hcp-api.ts lines 3-9,
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.ts
line 4, and
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx
line 4 to use import type for AwsAccountIdsResponse, OIDCConfigResponse,
OrganizationQuotaResponse, WizardBasePayload, WizardErrorResponse, and
SelectedSecret.

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 29-32: Update the aws_account_id field in the OIDCConfigReq type
from number to string so leading zeros in 12-digit AWS account IDs are
preserved.
- Around line 108-118: Update the request-body accumulation in the req data/end
handlers to preserve the exact payload: collect chunks as Buffers or explicitly
decode each chunk to strings, then concatenate with an empty separator rather
than the default comma. Ensure JSON.parse in the end handler receives the
original JSON without inserted delimiters or unsafe implicit conversions.
- Line 121: Update the accountPath construction in the rosa wizard request to
URL-encode the entire search query parameter value, preserving the existing
filter expression while encoding its spaces and special characters before
sending it upstream.

In `@backend/test/routes/rosaWizardApi.test.ts`:
- Around line 111-164: Update the OIDC config tests around the POST
/oidc-configs cases to define aws_account_id as a string and replace exact
query-string paths in both nock(API_HOST) handlers with .query() matching the
expected search parameter, so URL-encoded query values are accepted while
preserving the existing responses and assertions.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.ts`:
- Line 12: Update the queryKey construction in useFetchOIDCConfigs to safely
handle a nullish selectedSecret by using its optional client_id with an
empty-string fallback, or remove the enabled null check only if the
SelectedSecret type guarantees it is always defined. Ensure query initialization
cannot access client_id on nullish data before enabled is evaluated.

---

Nitpick comments:
In `@frontend/src/lib/rosa-hcp-api.ts`:
- Around line 3-9: Use type-only imports for the listed symbols: update
frontend/src/lib/rosa-hcp-api.ts lines 3-9,
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.ts
line 4, and
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx
line 4 to use import type for AwsAccountIdsResponse, OIDCConfigResponse,
OrganizationQuotaResponse, WizardBasePayload, WizardErrorResponse, and
SelectedSecret.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.ts`:
- Line 8: Rename the oidcConfigs parameter aws_account_id to awsAccountId in the
query key factory, and update its usage in the returned key tuple while
preserving the existing key structure.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.ts`:
- Around line 28-30: Update the fetch callback in useFetchOIDCConfigs to remove
the unnecessary async modifier and Promise<void> return type, leaving it as a
synchronous callback that only calls setAwsAccountId.
- Around line 32-37: Define a stable empty-array constant outside the hook in
useFetchOIDCConfigs, then replace the inline data ?? [] fallback with that
constant. Keep the existing data behavior unchanged when fetched data is
available.
🪄 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: 35da8d01-355c-4203-b911-e458ad4c4585

📥 Commits

Reviewing files that changed from the base of the PR and between d149900 and 569b0d8.

📒 Files selected for processing (11)
  • 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/queries/queryKeyFactory.test.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/queryKeyFactory.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useFetchOIDCConfigs.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
Comment thread backend/test/routes/rosaWizardApi.test.ts
Signed-off-by: David Aznaurov <daznauro@redhat.com>
Signed-off-by: David Aznaurov <daznauro@redhat.com>
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot mentioned this pull request Jul 21, 2026
18 tasks
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.

1 participant