With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depe

Hyrum's Law in Golang

submited by
Style Pass
2024-11-15 22:00:03

With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.

In other words, any behavior that can be observed in code — whether intentional or accidental — will eventually become something that someone, somewhere, relies on.

So in the code above, the author is acknowledging that the error message cannot be changed because it is likely being relied upon by someone, somewhere. Even though it might seem trivial to tweak the error message, doing so could cause unintended issues for anyone relying on this specific message. In this case, a seemingly small change could break existing code where someone depends on the exact phrasing of "http: request body too large".

This wasn't the only instance. I found similar comments referencing Hyrum's Law in Go's crypto/rsa and internal/weak packages as well.

Leave a Comment