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

panic while accessing undefined cf metadata annotations/labels #42

Open
cbarbian-sap opened this issue Feb 29, 2024 · 0 comments
Open
Assignees

Comments

@cbarbian-sap
Copy link
Contributor

In a couple of places we evaluate cf metadata annotations or labels like

parameterHash := *serviceInstance.Metadata.Annotations[annotationParameterHash]

(https://github.com/SAP/cf-service-operator/blob/main/internal/cf/instance.go#L43)

Under normal circumstances, this does not cause a problem, since the logic in cf-service-operator ensures that the labels/annotations were properly set, before reading them for the first time. However, in case someone changed things manually in the cf api, or if existing instances/bindings were incompletely adopted, the code might dereference a nil pointer, and therefore panic.

This should be handled in a more robust way. Proposal: have a wrapper method for accessing cf labels/annotations which first checks if the according key exists and the respective value is non-nil, and only then dereferences it.

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

No branches or pull requests

1 participant