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

Prevent nil pointer dereference #1083

Closed
mvrahden opened this issue May 30, 2021 · 0 comments · Fixed by #1084
Closed

Prevent nil pointer dereference #1083

mvrahden opened this issue May 30, 2021 · 0 comments · Fixed by #1084

Comments

@mvrahden
Copy link
Contributor

Contains*-Assertions panic when a nil instead of a string, slice, map etc. is injected.
Minimal example here:

var myMap map[string]interface{} // empty
// try an assertion on nested keys
// which effectively leads to a passing of nil
require.Contains(t, myMap["some-key"], "expected-nested-key") // <-- panic

Assertions should be robust against nil-injection and gracefully fail instead of panicking.

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 a pull request may close this issue.

1 participant