-
Notifications
You must be signed in to change notification settings - Fork 3
Providers mapping bug fix #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Providers mapping bug fix #332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in provider mapping by refactoring how provider types are resolved. Instead of looking up provider configurations by name and checking apiVersion patterns, it now directly extracts and normalizes the domain from the apiVersion string.
Key changes:
- Replaced
resolveProviderTypefunction withresolveProviderTypeFromApiVersionthat extracts domain from apiVersion - Removed dependency on
providerConfigsListparameter in the resolution logic - Updated test suite to reflect the new function signature and behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/components/Graphs/graphUtils.ts | Refactored provider type resolution to extract domain directly from apiVersion instead of iterating through provider configs |
| src/components/Graphs/graphUtils.spec.ts | Updated tests to validate domain extraction and "account." prefix removal logic |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/Graphs/graphUtils.ts
Outdated
| } | ||
| export const resolveProviderTypeFromApiVersion = (apiVersion: string): string => { | ||
| // Extract domain from apiVersion (e.g. "account.btp.sap.crossplane.io/v1alpha1" -> "account.btp.sap.crossplane.io") | ||
| const domain = apiVersion.split('/')[0] || ''; |
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback to empty string is ineffective because split('/')[0] will never return undefined or null. If apiVersion is an empty string, split('/')[0] returns an empty string. If apiVersion is undefined or null, this will throw an error. Consider adding a guard: const domain = apiVersion?.split('/')[0] || ''; or handle the undefined/null case before splitting.
| const domain = apiVersion.split('/')[0] || ''; | |
| const domain = apiVersion?.split('/')[0] || ''; |
andreaskienle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out Copilot's comment. I think it makes sense to safeguard against null/undefined being passed even though we have TypeScript. It's just a small change and an extra test.
Apart from that: 👍🏻
Fixes openmcp-project/backlog#279