All state action is subject to judicial review, where proportionality is a big factor.
It‘s an aspect of due process that is being reviewed and enforced by every court, up to the constitutional courts.
Example: the German criminal code threatens „up to five years“ in prison for theft.
That does not mean that a first-time theft of a not-too-valuable object could get you five years. Impossible. But not written in the statute itself. But even if a court was mad enough to hand out such a sentence, the revision stage would be swift and without any uncertainty.
Actually, it‘s hard to conceive of a first-time theft-offender going to prison, instead of paying a fine or at least having the prison sentence suspended.