Skip to content

FCN-248: cluster name check#6491

Merged
openshift-merge-bot[bot] merged 7 commits into
stolostron:mainfrom
davidaznaur:FCN-248-clustername-validation
Jul 22, 2026
Merged

FCN-248: cluster name check#6491
openshift-merge-bot[bot] merged 7 commits into
stolostron:mainfrom
davidaznaur:FCN-248-clustername-validation

Conversation

@davidaznaur

@davidaznaur davidaznaur commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

Ticket Summary (Title):
Check for uniquness of the cluster name in cluster service.

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 managed ROSA HCP cluster name uniqueness validation before submission.
    • Validates cluster name format and checks availability via a new backend endpoint.
    • Supports optional region-scoped name checking.
    • Shows clear validation feedback for invalid, unavailable, and failed checks.
  • Tests
    • Added backend and frontend coverage for the new cluster name uniqueness flow, including auth handling, validation errors, and hook behavior.

@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: 8e7077ff-38e5-4a0e-91fd-56ed95ad9244

📥 Commits

Reviewing files that changed from the base of the PR and between 4d331a3 and a490d32.

📒 Files selected for processing (9)
  • 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/useCheckClusterNameUniqueness.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.ts
  • frontend/webpack.config.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • backend/src/app.ts
  • frontend/src/lib/rosa-hcp-api.test.ts
  • backend/test/routes/rosaWizardApi.test.ts
  • frontend/src/lib/rosa-hcp-api.ts
  • frontend/webpack.config.ts
  • backend/src/routes/rosaWizardApi.ts
  • frontend/src/resources/rosa-hcp-wizard.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.ts
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.test.tsx

📝 Walkthrough

Walkthrough

Adds an authenticated backend endpoint to check cluster-name availability, frontend request and response types, an API wrapper, development proxying, and a React hook that exposes validation state and errors.

Changes

Cluster Name Uniqueness

Layer / File(s) Summary
Backend cluster-name check endpoint
backend/src/app.ts, backend/src/routes/rosaWizardApi.ts, backend/test/routes/rosaWizardApi.test.ts
Registers POST /cluster-name-check, validates lowercase cluster names, searches the clusters API, handles authentication and errors, and tests success, existing names, authentication, and invalid inputs.
Frontend API contract 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/webpack.config.ts
Defines request and response types, adds the typed API wrapper, proxies the endpoint, and verifies payloads including optional region.
Cluster-name validation hook
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.ts, frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.test.tsx
Adds memoized asynchronous validation with fetching state, taken-name errors, request failure handling, error clearing, and hook tests.

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant useClusterNameUniquenessCheck
  participant getWizardClusterNameUniqueness
  participant getClusterNameCheck
  participant ClustersAPI

  User->>useClusterNameUniquenessCheck: Check cluster name
  useClusterNameUniquenessCheck->>getWizardClusterNameUniqueness: Send credentials and payload
  getWizardClusterNameUniqueness->>getClusterNameCheck: POST cluster-name-check
  getClusterNameCheck->>ClustersAPI: Search clusters by name
  ClustersAPI-->>getClusterNameCheck: Return matching clusters
  getClusterNameCheck-->>getWizardClusterNameUniqueness: Return search response
  getWizardClusterNameUniqueness-->>useClusterNameUniquenessCheck: Return total
  useClusterNameUniquenessCheck-->>User: Return validation result
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 clearly matches the main change: adding cluster name checking for FCN-248.
Description check ✅ Passed The description follows the template and includes summary, link, type of change, checklist, and notes section.
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.

@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 (3)
backend/src/routes/rosaWizardApi.ts (1)

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

Consider adding region to the type for frontend contract alignment.

The frontend API defines an optional region property in its payload for this endpoint (ClusterNameCheckPayload in rosa-hcp-wizard.ts). Consider adding region?: string here so that the backend type is fully aligned with the frontend contract, even if it is not currently used in the OCM search filter.

♻️ Proposed refactor
 type ClusterNameCheck = Payload & {
   cluster_name: string
+  region?: 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 `@backend/src/routes/rosaWizardApi.ts` around lines 29 - 32, Add an optional
region?: string property to the ClusterNameCheck type so the backend payload
matches the frontend ClusterNameCheckPayload contract, without changing the
existing cluster-name validation or OCM search behavior.
frontend/src/resources/rosa-hcp-wizard.ts (1)

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

Use interface for object shapes.

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

♻️ Proposed refactor
-export type ClusterNameCheckPayload = {
+export interface ClusterNameCheckPayload {
   cluster_name: string
   region?: 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/resources/rosa-hcp-wizard.ts` around lines 35 - 38, Replace the
ClusterNameCheckPayload type alias with an interface while preserving its
cluster_name property and optional region property.

Source: Coding guidelines

frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniquness.ts (1)

30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Translate user-facing error strings.

Error messages displayed to users should be localized. As per coding guidelines, use i18next (useTranslation and t) for translated text, ensuring you import them strictly from ../lib/acm-i18next (or your configured internal alias) rather than react-i18next directly.

🤖 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/useCheckClusterNameUniquness.ts`
around lines 30 - 34, Update the cluster-name validation logic in the
uniqueness-check hook to translate both the “name already exists” and fallback
availability error messages through i18next’s useTranslation and t. Import these
strictly from ../lib/acm-i18next (or the configured internal alias), and
preserve the existing validation state and return behavior.

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 107-138: Update the request handling around the req.on('end')
callback: join chunks with no separator, move the try/catch inside the
asynchronous callback so JSON parsing and API errors are handled, and respond
with the existing 500 error helper on failure. Do not suppress jsonPost errors
or pass undefined to res.end; log the correctly spelled account-info error and
ensure every failure completes the response.

In `@frontend/src/resources/rosa-hcp-wizard.ts`:
- Line 58: Update the ROSAHCP response type’s items field to ROSAHCPCluster[] in
frontend/src/resources/rosa-hcp-wizard.ts (line 58). In
frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniquness.test.tsx,
change the empty mock at lines 27-27 to items: [] and wrap the mocked cluster
object at lines 35-41 in an array.

---

Nitpick comments:
In `@backend/src/routes/rosaWizardApi.ts`:
- Around line 29-32: Add an optional region?: string property to the
ClusterNameCheck type so the backend payload matches the frontend
ClusterNameCheckPayload contract, without changing the existing cluster-name
validation or OCM search behavior.

In `@frontend/src/resources/rosa-hcp-wizard.ts`:
- Around line 35-38: Replace the ClusterNameCheckPayload type alias with an
interface while preserving its cluster_name property and optional region
property.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniquness.ts`:
- Around line 30-34: Update the cluster-name validation logic in the
uniqueness-check hook to translate both the “name already exists” and fallback
availability error messages through i18next’s useTranslation and t. Import these
strictly from ../lib/acm-i18next (or the configured internal alias), and
preserve the existing validation state and return behavior.
🪄 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: f7517399-e992-45d1-9f79-96b6fc276dce

📥 Commits

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

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

Comment thread backend/src/routes/rosaWizardApi.ts
Comment thread frontend/src/resources/rosa-hcp-wizard.ts Outdated
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/cc @nitin-dhevar

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/cc @KevinFCormier

@davidaznaur

Copy link
Copy Markdown
Contributor Author

/test check

Comment thread frontend/src/lib/rosa-hcp-api.ts Outdated
Comment thread backend/src/routes/rosaWizardApi.ts Outdated
@davidaznaur

Copy link
Copy Markdown
Contributor Author

@KevinFCormier and @nitin-dhevar addressed all the comments, PTAL

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

@davidaznaur thanks for the updates. I ran this through an AI code review and posted the comments I think warrant further consideration here.

Comment thread backend/src/routes/rosaWizardApi.ts Outdated
Comment thread backend/src/routes/rosaWizardApi.ts
Comment thread frontend/src/lib/rosa-hcp-api.ts Outdated
Comment thread frontend/src/lib/rosa-hcp-api.ts
Comment thread backend/test/routes/rosaWizardApi.test.ts

@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

🤖 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 `@frontend/src/lib/rosa-hcp-api.ts`:
- Around line 79-85: Align the cluster-name-check response contract between the
backend route and the frontend wrapper around getWizardData, ensuring the
returned shape exposes the expected response.total data rather than an unwrapped
or mismatched body. Update the relevant backend/frontend types and serialization
consistently, then add an integration assertion covering the actual wire
response shape for cluster-name-check.

In
`@frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.ts`:
- Line 25: Update the uniqueness-check flow in useCheckClusterNameUniqueness to
prevent overlapping requests from applying stale results: pass the hook’s
AbortSignal to getWizardClusterNameUniqueness, or track monotonically increasing
request IDs and ignore responses from older checks before updating
clusterNameValidation. Add a test covering out-of-order responses and confirming
only the newest validation result is applied.
🪄 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: a851103a-ea1e-4525-b5f0-a767a5aa7994

📥 Commits

Reviewing files that changed from the base of the PR and between 4354217 and 4d331a3.

📒 Files selected for processing (7)
  • 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/useCheckClusterNameUniqueness.test.tsx
  • frontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/lib/rosa-hcp-api.test.ts
  • backend/src/routes/rosaWizardApi.ts
  • frontend/src/resources/rosa-hcp-wizard.ts

Comment thread frontend/src/lib/rosa-hcp-api.ts
@davidaznaur

Copy link
Copy Markdown
Contributor Author

/test unit-tests-sonarcloud

KevinFCormier
KevinFCormier previously approved these changes Jul 22, 2026
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-248-clustername-validation branch from 4d331a3 to a490d32 Compare July 22, 2026 19:01
@openshift-ci openshift-ci Bot added the lgtm label Jul 22, 2026
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidaznaur, KevinFCormier

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

@sonarqubecloud

Copy link
Copy Markdown

@openshift-merge-bot
openshift-merge-bot Bot merged commit f42754d into stolostron:main Jul 22, 2026
16 checks passed
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