Fixes panic on group database errors during host user reconciliation#53031
Fixes panic on group database errors during host user reconciliation#53031
Conversation
| require.NotPanics(t, func() { | ||
| closer, err = users.UpsertUser("alice", userinfo) | ||
| }) |
There was a problem hiding this comment.
I'm not sure this is how we should be testing this. You can make the argument that none of our code should panic (unless explicitly coded to do so), in which case we would have every test include a requires.NotPanics() wrapped around everything.
In this case, there was a panic due to mistaken error handling. Which says to me we need to test that the error handling is now correct, which means UpsertUser() returns an error when the group lookup returns an error. It is sufficient to just have the next line (require.Error(t, err)) and to remove the NotPanic assertion, as if it does panic, the test will still fail as panics in the code under test will always fail a test unless specifically caught and ignored.
There was a problem hiding this comment.
Great point. I included the require.NotPanic() just capture the specific regression this was guarding against, but you're right that it isn't actually testing anything valuable 👍 Updated!
628f8a0 to
348f51d
Compare
…p database errors
348f51d to
fe8a065
Compare
Fixes #53020
This fixes an issue where error returns from
user.LookupGroupByIDwould cause host user reconciliation to panic and crash the teleport process. A missingcontinuemeant that we would attempt to mark a group as found by accessing theIDfield on anilpointer.changelog: Fixed an issue causing the teleport process to crash on group database errors when host user creation was enabled