Merge pull request #47699 from vvoland/v23.0-47658

[23.0 backport] Fix cases where we are wrapping a nil error