Skip to content
engineering workbench.by StudyPort Academy
Learning path
Advanced20 minLESSON 05 / 6

Verifying a proposed fix

01

Understand the idea

A fix that makes an error message disappear is not automatically correct. Root cause and symptom suppression are different outcomes.

When the alarm goes quiet

AI patches love quiet. An empty catch, a broad default, a ?. chain that turns a programming mistake into undefined - each can make the demo stop throwing. Your verification question is sharper: is the gone, or only the alarm?

AI Lab · verify or suppress

AI fix: the TypeError is gone

cartTotal throws TypeError: Cannot read properties of undefined (reading 'price') when a missing catalog id leaves item undefined. A teammate pasted the error into a chat model and accepted this patch because the error message disappeared.

Proposed fix

function cartTotal(cart, catalog) {
  try {
    return cart.reduce((sum, line) => {
      const item = catalog[line.id];
      return sum + item.price * line.qty; // still blows up if item is missing
    }, 0);
  } catch {
    return 0; // error message gone - total quietly wrong
  }
}

Wrap the whole reducer in try/catch and return 0 on any error. The TypeError no longer surfaces.

Does this fix the root cause?

What a real verification checks

Re-run the failing case with an independently chosen expectation. Confirm the invalid state is rejected, repaired, or explicitly allowed by product policy. Then re-run a previously working case so the patch did not trade one bug for another. Message absence is a weak signal by itself.

Suppression versus root-cause repair
Patch shapeWhat goes quietWhat remains
empty catch → 0TypeErrorWrong total / missing item
swallow fetch errorNetwork rejectionStale UI state
default empty arrayUndefined crashLost distinction: empty vs failed
validate id + signalNothing usefulInvalid line cannot silently price

Common suppression patterns

Watch for catch blocks with no log, optional chaining used to dodge missing required data, and "return null and move on" suggestions that erase the difference between empty and failed. These patterns show up because they make screenshots look healthy.

Questions to ask every proposed fix

What invalid state existed? Does that state still exist after the patch? If it does, is it now explicit? What would a user or operator see? If the answer is "nothing, forever," you may have muted a production signal.

Only then ship the patch

Ship when the failing case passes for the right reason and the nearby cases still pass. That is verification. Anything less is optimism dressed as a diff.

02

Mental model

FOLLOW THE VALUE

error gone
symptom check
insufficient

Silence is not success.

01 / 03Trace the transformation

03

Live example

A missing catalog id yields 0 through an empty catch - a quiet wrong total labeled suppressed.

Opening editor…
LIVE PREVIEW
Console 0

Your console output appears here.

Saved on this deviceJavaScript · ES2022
04

Guided challenge

Label the patch honestly

The second log says fixed. Change it to suppressed.

Opening editor…
LIVE PREVIEW
Console 0

Your console output appears here.

Saved on this deviceJavaScript · ES2022

EXPECTED CONSOLE OUTPUT

0
suppressed
not-root-cause
verify
done

Hints 0/2

    Use all hints or make 3 failed runs (0/3).

    05

    Free sandbox

    Make a variation, test an assumption, or break the example on purpose. This draft is saved separately.

    Opening editor…
    LIVE PREVIEW
    Console 0

    Your console output appears here.

    Saved on this deviceJavaScript · ES2022
    06

    Quiz

    A quick check for understanding. Retry as often as you like; your learning path stays open.

    01What is symptom suppression?
    02How do you verify a proposed fix?

    Ready to call this one understood?

    Mark this lesson complete to earn 200 XP. You can always revisit it.

    Sign in to save progress
    Next lesson