Lesson 12 of 14 · 15m
Contracts You Can't Unship
Hyrum's Law: every observable behavior is someone's dependency, so additive changes and expand-contract migrations are the only safe edits.
The contract is not what you documented. It's what shipped — every field, every default, every error code, every observable quirk. Hyrum's Law, named for Google's Hyrum Wright: with a sufficient number of users, all observable behaviors of your system will be depended on by somebody. Your API's real surface is whatever a client somewhere parses, and there is always a client somewhere.
Ossification is what pretending otherwise costs
TLS 1.3 shipped in August 2018 and promptly discovered that years of middleboxes — firewalls, inspectors, load balancers — had ossified around the byte patterns of earlier versions. Connections presenting unknown version or extension fields were killed on sight. Browsers had to implement fallback dances, and the ecosystem got RFC 8701 (GREASE): clients deliberately send garbage extension values so the "unknown" code path stays exercised and extensibility doesn't rot away. Behaviors nobody exercises harden into stone — protocols, like APIs, live or die on what the other side tolerates.
The disciplines that work
Don't break userspace. The Linux kernel's first rule — Linus Torvalds enforces it by reverting regressions: if a kernel change breaks a userspace program, the kernel is wrong even when the program was wrong. Go made the same commitment in the Go 1 compatibility document back in March 2012 and has kept it since; it's why decade-old Go programs still build.
Additive changes only. A new field is safe — old clients ignore it. A removed field is someone's crashed parser. A renamed column is the old release, still running during your deploy, failing to find it. Even a new enum value breaks clients that switch exhaustively — protobuf's explicit handling of unknown enum values exists for exactly this reason.
Expand and contract. Renaming email to primary_email in production is five deploys where one looked sufficient:
ALTER TABLE users ADD COLUMN primary_email text; -- deploy 1
-- code dual-writes both columns -- deploy 2
UPDATE users SET primary_email = email WHERE primary_email IS NULL; -- backfill
-- readers switch to primary_email -- deploy 3
ALTER TABLE users DROP COLUMN email; -- deploy 4, only when safeThe deploy window where old and new code run simultaneously is the constraint most migration guides quietly skip — it's where the entire discipline lives. DROP COLUMN and NOT NULL added too early are the two commands that break rolling deploys; both get scheduled for the release where nothing old still runs.
Deprecation is a protocol, not a comment. Signal early — the Sunset response header (RFC 8594), deprecation notices, warning logs — then give consumers a real window. Kubernetes carried the extensions/v1beta1 Ingress API through a long documented deprecation before removing it in v1.22 (August 2021); the operators who ignored the notices found out in their upgrade incident reports.
Semver won't save you
MAJOR.MINOR.PATCH is a promise about intent, not impact. Minor versions break people constantly — a tightened validation rule, a changed default, an error message a client regexes. The version number tells consumers that you changed something; Hyrum's Law tells them what changed is whatever they happen to depend on.
Engines ossify too. document.all evaluates falsy in every modern browser — typeof document.all === 'undefined', if (document.all) never runs — because legacy pages sniffed it to detect IE, and the spec encodes the deception rather than break them. ES2019 had to make Array.prototype.sort stability mandatory: V8 shipped a stable sort in Chrome 70 and enough shipped code already depended on that ordering that the standard absorbed the implementation. Whatever your system observably does is what the next version must keep doing — bugs included.
Try this: diff your API or schema against what you shipped a year ago. List the observable behaviors — fields, defaults, error shapes, ordering guarantees — that a client could have built on. Anything on that list is now load-bearing, whether or not it was in the docs.
Pitfalls
- Repurposing a field because it looks "unused" — it isn't unused, it's unmonitored.
- A default is a contract; changing one is a breaking change wearing a patch's clothes.
- Status codes are parsed, not read:
404vs410,400vs422change client behavior. - Version negotiation beats migration:
Accept: application/vnd.api.v2+jsonis cheaper than a flag day.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
What is Go? The Language Google Built for Production Engineering
Go is a statically typed, compiled language built at Google in 2009. It compiles to a single binary with no runtime dependency, starts in milliseconds, and handles concurrency through goroutines and channels. Docker, Kubernetes, and Terraform are all written in Go. Here is why.
What is Rust? The Language That Makes Systems Programming Safe
Rust eliminates entire categories of bugs — null pointer dereferences, buffer overflows, data races, use-after-free — at compile time with no runtime overhead. Microsoft, Google, Amazon, and the Linux kernel all use it for systems code.
What is Java? The Language That Runs Minecraft, Your Bank, and Half the Internet
Java has been declared dead approximately forty times since 1995. It still runs Minecraft, Android, LinkedIn, Twitter's backend, and the financial systems that process your paycheck. Here is what the language actually is, how the JVM works, and why it refuses to die.
What is Python? Enterprise, Data Science, and the Backend of the Web
Python runs Instagram, Dropbox, Netflix, Spotify, and Reddit. It trains the models that power modern AI. It processes petabytes of data in enterprise pipelines. And I ignored it for years because I thought it was just for academics. Here is what changed my mind.