Directing Work You Cannot Read

The Day The API Dies

Your dependency tree is a trust graph and your package manifest is a contract portfolio. The vendors that killed products did not go down, they changed their pricing page with notice.

Every dependency is a bet that somebody else keeps doing something for you, on terms you can live with, for as long as you need it. Most of those bets are good. The discipline is knowing which ones you have made, which would genuinely hurt, and what you would do on the morning one stops.

Hyrum's Law, and why version numbers lie

With enough users, every observable behaviour of your system becomes something somebody depends on, documented or not. That is Hyrum's Law, and it makes semantic versioning a promise about intent rather than a guarantee about behaviour. A patch release can break you because you depended on something the author never considered part of the interface: an error message, an ordering, a timing, a field that happened to be present. It runs in your direction too: the undocumented field in your API response is load-bearing for a customer now, and removing it is a breaking change whatever your version number says.

The policy that works sits between the two popular extremes. A caret range auto-accepts minor and patch releases from strangers, which Hyrum's Law guarantees will eventually break something. Never upgrading means taking every accumulated breaking change at once, on the day an advisory forces you to. The shape that holds: lockfile committed, continuous integration installing exactly from it with npm ci rather than npm install, upgrades on a schedule in small batches, and a hard pin only where a version is load-bearing, with the reason written next to it.

Your dependency tree is a trust graph

The useful way to read an install is not as code you received but as people you trusted, most of whom you cannot name. Each incident below has a different mechanism, and the mechanisms are what you defend against.

  • left-pad, March 2016. An eleven-line package was unpublished and builds broke across the ecosystem. The lesson is reach rather than malice: trivial packages sit underneath everything.
  • event-stream, 2018. A tired maintainer handed the package to a helpful volunteer, who added code that stole cryptocurrency from one specific downstream application. The attack vector was maintainer fatigue, and there is no patch for that.
  • colors and faker, January 2022. The maintainer himself shipped an infinite loop into packages thousands of projects depended on.
  • xz utils, CVE-2024-3094, early 2024. A multi-year social engineering campaign in which a patient contributor became a trusted co-maintainer and inserted a backdoor reachable through the SSH path on major distributions. It was found because one developer went looking for roughly half a second of unexplained login latency.
  • polyfill.io, mid-2024. The domain changed hands and began serving malicious code, conditionally, to visitors of sites embedding its script tag, suppressing itself when it detected inspection, which is why it ran for months. Nothing on those sites changed. The thing they loaded at runtime from a domain they did not control did.

There is also a class none of those names: attacks that steal publishing credentials from a build pipeline and use them to publish further compromised packages, propagating on their own. The defences are the same: no long-lived publish tokens, scoped secrets in continuous integration, a committed lockfile so a new malicious version cannot arrive without a deliberate change, and separation between the credential that builds and the one that deploys. Software Supply Chain Failures entered the current OWASP Top Ten as a named category, which is the formal acknowledgement that this stopped being an edge case.

The habit to drop today is loading a third-party script at runtime from somebody else's domain. Self-host it at a pinned version. If you must load it remotely, use Subresource Integrity, and know that an integrity hash cannot cover a script whose content is designed to vary, which is exactly what polyfill and tag-manager services are, and why those are the ones that bite.

A package manifest is a contract portfolio nobody read

Licences are commercial terms wearing a technical disguise. MIT and Apache 2.0 are permissive, with Apache 2.0 adding an express patent grant. The GPL family is copyleft. The one to recognise on sight is the AGPL, whose section 13 extends the obligation to provide source to users interacting with the software over a network, aimed precisely at hosted products, which makes an AGPL dependency inside a SaaS product a commercial decision rather than a technical one. Several widely used licences are source-available rather than open source, including BSL, SSPL and the Elastic licence, with real use restrictions. Run a licence report once and keep it current, because diligence will run the same report, and an acquirer finding an AGPL component in your core service is a conversation to have before you are in a deal.

Vendors do not die of outages, they die of pricing pages

The verified list is instructive because none of these were failures. Heroku ended its free tier on 28 November 2022. Twitter blocked third-party clients outright in January 2023 and changed its developer terms to forbid them, then cut off free API access and repriced into paid tiers weeks later. Reddit's 2023 API repricing closed Apollo and others. Google Maps repriced in 2018 and bills jumped for sites that had embedded it years earlier. Parse announced its shutdown in January 2016 and closed a year later, after being acquired.

Every one was a deliberate decision by a working company, announced with notice, and products died anyway. Technical redundancy does not protect you from a pricing page, and an uptime guarantee says nothing about commercial intent. The risk is not that your vendor breaks, it is that their strategy changes and you were built on the previous one.

The assessment, for your top five

  • Can you get your data out today, in a usable form, without asking them? If the answer involves a support ticket, you do not have your data.
  • How long would a migration take, in weeks, with a named alternative? We would figure it out is the same answer as no plan.
  • Is there a second supplier with a similar interface shape, or is this capability uniquely theirs? Uniqueness is exactly what makes a vendor attractive and what makes them dangerous.
  • What share of your product's value do they provide? When the answer is most of it, you are a reseller with extra steps and should price and plan accordingly.
  • What do they hold that you keep nowhere else? Anything existing only in a vendor's dashboard is not yours.

The cheap structural defence is a thin adapter: one module of your own that calls the vendor and exposes your types to the rest of your code. It costs an hour and makes replacement a contained job rather than a search through every file. What is not worth building is a full abstraction over two providers you do not use.

Operating a dependency

Rate limits and quotas are part of the contract and they change. Cache responses wherever correctness allows, and hold to the per-dependency degradation decision from the latency lesson. Then do the unglamorous thing: subscribe to the status page and changelog of every vendor in your critical path and make sure a human reads them. The notice period on a repricing is the only cheap time to react, and it is almost always wasted.

Key takeaways

1Hyrum's Law makes semantic versioning a promise rather than a guarantee, in both directions: your undocumented field is somebody's dependency too.
2Commit the lockfile, install from it in CI with npm ci, upgrade on a small regular cadence, and pin hard only where the reason is written down.
3left-pad, event-stream, colors, xz utils and polyfill.io each failed by a different mechanism, and two were the maintainer. Stop loading runtime scripts from domains you do not control.
4A package manifest is a licence portfolio: AGPL section 13 reaches hosted software over a network, and BSL, SSPL and Elastic are source-available with restrictions.
5Heroku, Twitter, Reddit, Google Maps and Parse killed products by business decision with notice, not by outage. Score your top five on data exit, migration time, second supplier and share of value.

This is one lesson of 541.

The whole Foundation is free — 16 subjects, beginner to advanced. Sign in to track what you have read, take the end-of-module quizzes, and use the terminal.