Skip to content

12.7 A breaking dependency upgrade

A major dependency release can change runtime behaviour without changing any source-level contract. Your code still compiles, the API you call still has the same signature, and yet a default, a timeout, a serialization detail, or the performance profile is different. This drill practices containing such a change and keeping a reproducible rollback, turning the practice of Dependency upgrades in Software Engineering into an operational runbook.

Concepts from other sections (4)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

The discipline is the one from The API v2 migration: gates written before the change, evidence that measures behaviour, and a rollback that needs no thought. What is new here is isolation. Because the change comes from someone else’s code, you control it by changing exactly one thing at a time.

The section states the principles and the drill scenario, lists what a correct runbook must cover, and derives the procedure, ending with the model runbook docs/runbooks/DependencyUpgrade.md. Try to write the procedure yourself before you read the solution.

Learning objectives

  • Explain why a passing build is weak evidence for a dependency upgrade, and what evidence replaces it.
  • Isolate a change to one dependency and inspect its resolved graph for transitive bumps.
  • Gate a deploy on contract suites and a like-for-like load comparison against the last known good image.
  • Keep rollback a redeploy of a tagged image rather than a rebuild.

Inspect the resolved dependency graph and release notes. Change one dependency, keep lockfiles, run the focused contract suite, and compare the same load profile before deployment. Change one dependency at a time, with the lockfile committed, so any difference has one cause and the rollback is a revert of one diff. Deploy only after the gates pass, and keep the last known good image tagged so rollback is a redeploy, not a rebuild.

Upgrade the designated major version in a scratch branch. Build, run native and contract tests, then compare latency and error distributions with the last known good image. Deploy only after the gates pass.

A runbook for this change is complete when it answers five questions:

CaseWhat the runbook must containWhy it matters
Owner and scopethe one dependency, its old and new version, and the release notes’ breaking changesa single cause for any difference
Reproducible buildthe lockfile diff, a clean build, and the image digestthe same input gives the same artifact
Gatesnative and contract test suites, then the saved load profile against the last known good image, with thresholdsbehaviour, not just compilation
Rollbackthe last known good image tag and the revert commitrestoring service needs no rebuild
Verificationpost-deploy SLO burn and error rates compared with beforedone means measured

What could a dependency change break? Anything it touches at runtime: defaults, timeouts, serialisation, performance. Compilation success says almost nothing, so the evidence must be tests that exercise contracts plus a load comparison.

Isolate the cause. Upgrading several dependencies at once makes any regression ambiguous. Change one dependency per change, with its resolved graph inspected (go mod graph, cargo tree, uv pip tree) so transitive bumps are visible.

Make it reproducible. The lockfile pins the whole graph; committing it means the canary, the deploy, and the rollback all use exactly the tested set.

Compare like with like. Run the same load profile (rate, mix, seed, duration) against the last known good image and the candidate, comparing latency and error distributions, not single numbers.

Rollback is a redeploy. Keep the previous image tag: reverting the commit restores the source, and the image tag restores production at once.

The procedure written out as docs/runbooks/DependencyUpgrade.md:

# Runbook: dependency upgrade
Owner: the service owner of the component being upgraded.
## Preconditions
- One dependency, old and new versions named; release notes read for breaking changes.
- The resolved graph diff reviewed (`go mod graph`, `cargo tree`, `uv pip tree`).
- The last known good image tag recorded.
## Gates (on a branch)
1. Update the dependency and its lockfile only; build cleanly from scratch.
2. Run the native and contract suites (OpenAPI conformance, ABI and format tests).
3. Run the saved load profile against the last known good image and the
candidate; compare TTFT, TPOT, end-to-end latency, and error rate
distributions. Gate: p95 within 5% and error rate not higher.
## Deploy and rollback
Deploy the candidate image. Rollback trigger: a burn-rate alert, or error rate
above the pre-deploy baseline for 10 minutes. Action: redeploy the last known
good tag, then revert the commit.
## Verification
SLO burn below 1 for 24 hours after the deploy; the decision and the load
comparison attached to the change.

One change per deploy keeps attribution and rollback trivial. A load comparison against the last good image catches performance and timeout changes that functional tests miss. And the alternative, waiting for production to tell you, is expensive: a regression found under real traffic has already spent error budget, while the same load profile finds it on a branch.

Three shortcuts account for most painful upgrades:

PitfallSymptomHow the solution avoids it
Several dependencies bumped togethera regression with many possible causes; rollback undoes unrelated fixesone dependency and its lockfile per change
Only compile and unit tests runruntime behaviour or latency changes reach productioncontract suites and the saved load profile gate the deploy
No recorded last known good imagerollback requires a rebuild under pressurethe tag is a precondition

The practice this runbook relies on is Dependency upgrades, and it follows The API v2 migration. When an upgrade or any other change slips through and costs latency, A performance regression bisect finds the commit responsible. To compare this inject with the adjacent drills and reuse the same containment and verification fields, see the chapter opening.

  • Lockfile: the file that pins the whole resolved dependency graph so every build uses the same set.
  • Resolved graph: the full set of direct and transitive dependencies actually selected, shown by go mod graph, cargo tree, or uv pip tree.
  • Contract suite: tests that exercise behaviour at an interface (OpenAPI conformance, ABI and format tests).
  • Last known good image: the tagged artifact that already ran in production, kept so rollback is a redeploy.
  • A dependency upgrade can change runtime behaviour with no source-level change, so evidence must be behavioural: contract tests and the same load profile.
  • Change one dependency at a time, lockfile committed, so a difference has one cause and rollback reverts one diff.
  • Compare distributions under a like-for-like load profile against the last known good image, with thresholds set in advance.
  • Keep the last known good image tagged so rollback is a redeploy, not a rebuild.
  1. Why upgrade one dependency at a time?
    AnswerSo any behavioural difference has exactly one cause and the rollback is reverting one diff.
  2. Why is a passing build not enough evidence?
    AnswerA dependency can keep its API and change defaults, timeouts, or performance; only tests that exercise behaviour and a load comparison see that.
  3. Why keep the last known good image tag?
    AnswerRollback then means redeploying an artifact that already ran in production, which is faster and safer than rebuilding the old source.
  4. Why inspect the resolved graph and not just the one line you changed?
    AnswerUpgrading one direct dependency can pull in new versions of its transitive dependencies. The graph diff makes those visible, so "one change" really is one change.