Skip to content

Conversation

Hubert-Szczepanski-SAP
Copy link
Contributor

@Hubert-Szczepanski-SAP Hubert-Szczepanski-SAP commented Oct 1, 2025

What this PR does / why we need it:

Changing the way we map resources from only name to name + apiVersion (${name}-${apiVersion})

After change:
image

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

@Hubert-Szczepanski-SAP Hubert-Szczepanski-SAP changed the title create resources on graph based on name AND apiVersion fix: Resources on graph based on name AND apiVersion Oct 1, 2025
@andreaskienle andreaskienle requested a review from Copilot October 2, 2025 10:13
Copy link
Contributor

@Copilot Copilot AI left a 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 changes the resource identification strategy in the graph component from using only the resource name to using a combination of name and API version. This prevents collisions when resources have the same name but different API versions.

Key changes:

  • Modified resource ID generation to include both name and API version
  • Updated reference resolution to consistently use the new ID format
  • Restructured code to apply the new ID format to both parent and extra references

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const id = item?.metadata?.name;
const name = item?.metadata?.name;
const apiVersion = item?.apiVersion ?? '';
const id = `${name}-${apiVersion}`;
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ID generation could create collisions when resource names contain hyphens. For example, 'my-resource' with apiVersion 'v1' would have the same ID as 'my' with apiVersion 'resource-v1'. Consider using a different separator like '::' or implement a more robust encoding scheme.

Copilot uses AI. Check for mistakes.

].filter(Boolean) as string[];
const createReferenceIdWithApiVersion = (referenceName: string | undefined) => {
if (!referenceName) return undefined;
return `${referenceName}-${apiVersion}`;
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference ID generation uses the current resource's apiVersion for all references, but referenced resources may have different API versions. This could create incorrect references to non-existent nodes in the graph.

Copilot uses AI. Check for mistakes.

andreaskienle
andreaskienle previously approved these changes Oct 2, 2025
Copy link
Contributor

@andreaskienle andreaskienle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can check Copilot's suggestions, to me it seems fine. 🙏

One thought: since this was a bugfix, it might make sense to add some unit tests. We could extract the transformation logic (⁠providerConfigsList + ⁠managedResourcestreeData, lines 100-184) into a separate function and test it properly. What do you think? Could also do it as a separate backlog item.

Copy link
Contributor

@andreaskienle andreaskienle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Hubert-Szczepanski-SAP Hubert-Szczepanski-SAP merged commit 71764a7 into main Oct 7, 2025
5 checks passed
@Hubert-Szczepanski-SAP Hubert-Szczepanski-SAP deleted the fix/visualise-resources-on-graph-by-name-and-version branch October 7, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants