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

Automated backport of #1447: Fix panic due to invalid nil check #1448

Conversation

tpantelis
Copy link
Contributor

Backport of #1447 on release-0.16.

#1447: Fix panic due to invalid nil check

For details on the backport process, see the backport requests page.

This code results in a panic if the underlying value of 'result'
is nil:

func(result interface{}) (bool, string, error) {
    if result == nil {
        return false, "gateway not found yet", nil
    }

    gw := result.(*unstructured.Unstructured)
    haStatus := NestedString(gw.Object, "status", "haStatus") => PANIC
    ...
})

But it first checks if 'result' is nil so how can this be? A simple nil check
does not work because interfaces in Go contain both a type and a value. In
this case, we want to check for nil after casting.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@submariner-bot
Copy link

🤖 Created branch: z_pr1448/tpantelis/automated-backport-of-#1447-upstream-release-0.16

@tpantelis tpantelis enabled auto-merge (rebase) October 31, 2023 11:40
@tpantelis tpantelis merged commit e306910 into submariner-io:release-0.16 Oct 31, 2023
45 of 46 checks passed
@submariner-bot
Copy link

🤖 Closed branches: [z_pr1448/tpantelis/automated-backport-of-#1447-upstream-release-0.16]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants