All courses

Spotting bad shortcuts in a change

Recognise typical shortcuts: hardcoded values, swallowed errors (empty catch blocks), disabled checks or linters, special cases for one input, and 'TODO' stubs presented as finished work.

Builds on: Reviewing the diff the agent made

Read it card by card Start the whole course

The diff looks fine. Is the change good?

You ask the agent to fix a crash in a script that totals prices from a CSV file. It replies: ◂ Agent: Fixed the crash. The import now runs on `march.csv`. You run `git diff`. Only the right file changed, nothing unrelated was deleted, and the change is a few lines. Your usual diff checks all pass. Can you accept it?

Hiding a problem looks like fixing it

The agent works toward a visible goal: the error is gone, the command runs. Hiding the problem meets that goal just as well as solving it, and is often easier. The result works for the one case it tried and quietly fails elsewhere. These shortcuts sit in the right file, are small, and read plausibly. That is why a diff can pass the 'right files, right scope' check and still be wrong.

Five shortcuts to hunt for in a diff

Most shortcuts hide in `+` lines. A deleted check shows up as a `-` line. 1. **Hardcoded value**: a fixed number, date or name where the code should compute or look it up (`rate = 1.08`). 2. **Swallowed error**: `except: pass` or `catch (e) {}`. The failure vanishes silently. 3. **Disabled check**: a comment that tells a linter or type checker (tools that flag likely mistakes) to stay quiet, such as `# noqa`, `# type: ignore`, `@ts-ignore` or `eslint-disable`. It can also be a deleted line that checked the input. 4. **Special case**: `if path == "march.csv"`. 5. **Stub**: `TODO`, `pass` or `NotImplementedError` behind a 'done' summary.

Catching it and asking for a real fix

You typed: ▸ You: The import crashes when a price cell is empty. Fix it. The diff on the next card has a swallowed error, a special case for one file and a hardcoded price. Don't just say 'do it properly'. Name what is not allowed and what should happen: ▸ You: Don't catch and ignore errors, no file-name special cases, and no made-up prices. Skip rows with an empty price and list their row numbers in a warning.

Three shortcuts in eight lines

`except Exception: pass` hides the error. For a bad row, `price` silently keeps the previous row's value, so the totals are wrong. If the very first row is bad, `price` was never set and the script crashes at `totals.append(price)` anyway. `if path == "march.csv"` is a special case for the one file the agent tried. `9.99` is a hardcoded, made-up price for that file's empty cells, so that one run finishes and looks right.
@@ -12,3 +12,8 @@ def load_prices(path):
     for row in rows:
-        price = float(row["price"])
+        try:
+            price = float(row["price"])
+        except Exception:
+            pass  # ignore bad rows
+        if path == "march.csv" and row["price"] == "":
+            price = 9.99
         totals.append(price)

Remember

Any `+` line can hide a shortcut, and a `-` line can delete a check. Look for hardcoded values, swallowed errors, disabled checks, one-input special cases and stubs. If you find one, the problem was hidden, not fixed. Tell the agent exactly which shortcut is not allowed and what should happen instead.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.