FCN-248: cluster name check#6491
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughAdds 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. ChangesCluster Name Uniqueness
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
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
backend/src/routes/rosaWizardApi.ts (1)
29-32: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding
regionto the type for frontend contract alignment.The frontend API defines an optional
regionproperty in its payload for this endpoint (ClusterNameCheckPayloadinrosa-hcp-wizard.ts). Consider addingregion?: stringhere 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 valueUse
interfacefor object shapes.As per coding guidelines, use
interfacefor object shapes that may be extended, reservingtypefor 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 winTranslate user-facing error strings.
Error messages displayed to users should be localized. As per coding guidelines, use i18next (
useTranslationandt) for translated text, ensuring you import them strictly from../lib/acm-i18next(or your configured internal alias) rather thanreact-i18nextdirectly.🤖 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
📒 Files selected for processing (9)
backend/src/app.tsbackend/src/routes/rosaWizardApi.tsbackend/test/routes/rosaWizardApi.test.tsfrontend/src/lib/rosa-hcp-api.test.tsfrontend/src/lib/rosa-hcp-api.tsfrontend/src/resources/rosa-hcp-wizard.tsfrontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniquness.test.tsxfrontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniquness.tsfrontend/webpack.config.ts
|
/cc @nitin-dhevar |
|
/cc @KevinFCormier |
|
/test check |
|
@KevinFCormier and @nitin-dhevar addressed all the comments, PTAL |
KevinFCormier
left a comment
There was a problem hiding this comment.
@davidaznaur thanks for the updates. I ran this through an AI code review and posted the comments I think warrant further consideration here.
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
backend/src/routes/rosaWizardApi.tsbackend/test/routes/rosaWizardApi.test.tsfrontend/src/lib/rosa-hcp-api.test.tsfrontend/src/lib/rosa-hcp-api.tsfrontend/src/resources/rosa-hcp-wizard.tsfrontend/src/routes/Infrastructure/Clusters/ManagedClusters/components/rosahcp/queries/useCheckClusterNameUniqueness.test.tsxfrontend/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
|
/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>
4d331a3 to
a490d32
Compare
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|



📝 Summary
Ticket Summary (Title):
Check for uniquness of the cluster name in cluster service.
Ticket Link:
Type of Change:
✅ Checklist
General
ACM-12340 Fix bug with...)If Feature
If Bugfix
🗒️ Notes for Reviewers
Summary by CodeRabbit