MongoDB collection.find(whatever).first() can return null

I’m seeing this false positive too in my project.

When I try your example Michael I see the error go away. However if you invert the null check the error appears. “user” can be null and what if you need to “doSomething()” if its null. Sonar says to change the condition so that is does not always evaluate to false.

The “first()” method is annotated with Nullable, what are we missing here?

squid:S2583

EDIT:
Looking over other posts it looks like mongodb Nullable isn’t in the list of: