Skip to content

Conversation

Ghostbird
Copy link
Contributor

Fixes #140

The findResByName function returned the first resource whose name contained the search string.

Now it instead returns the shortest-named resource whose name contains the search string. The assumption is that if there are multiple matches, one is a longer name, that coincidentally also contains the search string, but is not the intended resource. The shortest one is the actual intended match.

There may still be edge cases where this too fails. Especially when you get creative with kubernetes name generation.

Copy link
Owner

@benc-uk benc-uk left a comment

Choose a reason for hiding this comment

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

Thank you so much for the PR ☺️

I think we can simplify this even more!
I'll admit I let AI assistant auto create this function and wasn't paying attention! The logic should be a simple exact match not some substring or partial

I tested this with the same pod & service names you have and it works now

@Ghostbird Ghostbird force-pushed the 140-error-in-graph branch from ba0056b to 7d4a0a5 Compare July 14, 2025 06:42
@Ghostbird
Copy link
Contributor Author

Changed the branch history and force pushed, since it gives a cleaner fix:

  • Use exact name match
  • Replace filter, sort, [0] with find.

@Ghostbird Ghostbird changed the title Use shortest match Use exact match Jul 14, 2025
@Ghostbird Ghostbird changed the title Use exact match Find exact match Jul 14, 2025
@benc-uk benc-uk merged commit cd92027 into benc-uk:140-error-in-graph Jul 14, 2025
benc-uk added a commit that referenced this pull request Jul 14, 2025
Co-authored-by: Gijsbert ter Horst <Ghostbird@users.noreply.github.com>
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