In #1433 we updated this method to basically never return an error, but kept the signature the same to keep the change localized.
Post 0.17 release, we need to take up a bigger refactor and make the method infallible, and then update all the call-sites to handle that.
This should significantly simplify the method overall.