It's less clear the way it's done but the error arose not that often so... (2 times so far).
I avoid comparing strings and prefer catching the error if any.
Shout out if you disagree ;)
Related https://sentry.softwareheritage.org/share/issue/518b76d7d7d244f8b88d1757599035b2/