Skip to content
mentoor

Topic 3 of 4 · 4 min read

Reviewing AI hotfixes during an outage

Goal: Judge an AI-proposed hotfix during an outage and choose between applying it, reverting the last deploy or narrowing the fix.

During an outage, revert the last deploy if that is safe, and apply an AI-written hotfix only when it is the smallest possible change and a second person has read it.

Check yourself · 1 of 3

An outage starts four minutes after a deploy, and the previous version ran fine for a week. What is usually the best first move?

Choose one answer

Why it matters

Pressure makes people skip review. An assistant such as Claude Code, Cursor or Copilot will happily produce a fix in thirty seconds, and it will look reasonable. It may also fix a symptom, touch unrelated code or add a new bug. A bad hotfix under pressure can extend the outage. The goal is to stop the harm first and understand the cause second.

How to do it

  1. Ask: can we revert? If the outage began right after a deploy, and the previous version is known good, revert. It is a tested state and usually faster than a new fix. Watch for deploys that included a database migration or a data change, which a revert does not undo.
  2. If a fix is needed, make it small. One file, a few lines, ideally a flag or a guard. Tell the assistant: "smallest change that stops the error; no refactoring, no new dependencies, no unrelated edits".
  3. Do a short real review. Two minutes, two questions. What exactly changed (read the diff, not the summary)? What else can this touch (callers, other paths, data)? A second human reads it, even on a call.
  4. Verify the effect. Use the metric that raised the alarm. Does the error rate fall? Watch for five minutes.
  5. Write down the follow-up. Open a ticket for the proper fix, the missing test and the review you shortened. A hotfix that nobody follows up becomes permanent.

Before and after

An assistant proposes this for a crash on empty carts:

- total = sum(i.price * i.qty for i in cart.items)
+ try:
+     total = sum(i.price * i.qty for i in cart.items)
+ except Exception:
+     total = 0

It stops the crash, but now any error in pricing quietly charges zero. The narrower fix:

+ if not cart.items:
+     return 0
  total = sum(i.price * i.qty for i in cart.items)

What goes wrong

  • Swallowing errors. Broad except blocks hide the bug and create wrong data.
  • Scope creep. The assistant also "cleans up" nearby code. Reject extra lines.
  • Skipped tests. Nobody adds a regression test, so the bug returns.
  • Reverting past a migration. Old code meets a new schema and fails in a new way.

Examples

Revert beats a clever fix

Error rate rose to 12% four minutes after release 88. The assistant proposes a 40-line patch to the new caching layer. The release had no migration, and release 87 ran cleanly all week. The lead reverts to 87, the rate drops in two minutes, and the patch is reviewed calmly the next day.

Scope creep in a hotfix

  def parse_amount(s):
-     return float(s)
+     s = s.strip().replace(",", "")
+     return round(float(s), 2)

The crash was only on an empty string. The extra replace turns 1,5 (one and a half in some locales) into 15. Narrow it to if not s: return 0.0.

Key points

  • If the outage began with a deploy and the previous version is known good, reverting is usually the fastest safe step.
  • Check whether the deploy included a migration or data change before you revert.
  • Ask the assistant for the smallest change that stops the error, with no refactoring or unrelated edits.
  • Review the diff itself, not the summary, with a second person, even if it takes only two minutes.
  • Confirm the fix with the metric that raised the alarm, then record follow-up work for the proper fix and test.

Common mistakes

  • Applying an AI fix without reading the diff because the summary sounds right.
  • Reverting a deploy that included a database migration without checking compatibility.
  • Accepting a broad exception handler that hides the real error.
  • Closing the incident without a ticket for the proper fix and a regression test.

Check yourself · 2 of 3

An assistant offers a hotfix that also renames two functions and updates a dependency. What should you do?

Choose one answer

Check yourself · 3 of 3

A hotfix wraps a pricing calculation in a broad try and except that returns 0. What is the main danger?

Choose one answer

Practice items, not counted towards your mastery.

Start here