>> It was used before, once every startup of the application so it was deemed OK.
> And that's where someone went wrong. There should have been a test, or runtime failure, or even better (but more difficult) a compilation failure if someone misuses something in that way.
I don't subscribe to the idea of creating so much additional code for a relatively simple constraint.
Code should be dense. Dense means a lot of important constraints implemented in small amount of code.
Of course this is not yet guarantee that the code is readable and easy to maintain, but as a general rule, a codebase that has 5 times the amount of code to implement same functionality will more likely than not be less maintainable. That is because it is just more difficult to work with that much code.
> There should have been (...) or even better (but more difficult) a compilation failure if someone misuses (...)
In this particular case what I suggested was to move the original function with generic name from a generic utility package to a specific module package with specific name.
See? Compilation failure, not difficult at all.