Skip to content
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

housekeeping: fix catalog apps generation and validation. #2360

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

patrickdappollonio
Copy link
Member

@patrickdappollonio patrickdappollonio commented Jan 13, 2025

Description

Doing the AWS STS work I found this function that seems to be buggy. Not only loading information into each catalog app wasn't working because it was operating on a copy of the original value, but the error message wasn't being handled at all.

The function returned 2 important values, a boolean that would say if the catalog was incorrect and an error that would say if the catalog was incorrect, thus making it if err != nil to always have a non-true bool return.

If the callers were handling this in a way that would require the "bug" to be there then this would break the current flow.

Related Issue(s)

Fixes #

How to test

if catalogApps == "" {
return true, gitopsCatalogapps, nil
// No catalog apps to install
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously we were returning an empty slice, but now we are returning nil. Will downstream consumers of this be able to handle that?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good question!

In Go, a nil slice doesn't panic when sized (with len()) or iterated with range. The only time it would panic is if without range you attempt to access one of its non existent members.

If that's the case though, we want to see that failure because it means you didn't handle the error correctly 😆

Returning a non-nil slice here would just "cover the sun with a finger" but wouldn't stop you from getting a panic if you're trying to access the first element of a zero-length slice.

@nathan-nicholson nathan-nicholson changed the title Fix catalog apps generation and validation. housekeeping: fix catalog apps generation and validation. Jan 15, 2025
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