// Set the namespace if a collection was found, as opposed to nothing or a view.
if (ctx) {
query_request_helper::refreshNSS(ctx->getNss(), findCommand.get());
}
make it seem like refreshNss should only be evaluated if the collection exists in ctx, which is of type boost::optional<AutoGetCollectionForReadCommandMaybeLockFree>. But it's actually only checking whether the optional is populated. But the optional is always populated so refreshNss always runs.
It should probably be if (*ctx) or the code should be rewritten to not use an optional, but that might be difficult since we manually reset the optional later on.