AI code review · Self-paced workshop

4. Ask AI questions you can verify

Practise understanding changes, checking AI findings, and making review decisions you can defend.

Workshop index · Download all examples and lessons

Time: 35 minutes. Prerequisite: lesson 3. Outcome: an evidence log that distinguishes observations, hypotheses, and unresolved assumptions.

Continue with the request adapter. The author wants a shorter defaulting expression. Your task is to determine whether it preserves the written contract.

Ask one question at a time

A broad “review this code” request can be useful for an initial survey. For investigation, ask a narrower question:

Compare baseline and candidate for an omitted field, zero, null, false, and a positive integer. For each, give the value after defaulting and the resulting response. Do not assume truthiness and field absence are equivalent.

Run examples yourself before treating a generated table as evidence. A model can confidently produce the right table for the wrong version of a file.

Recorded review

This is a constructed teaching example:

“The new fallback makes zero, null, and false become one, so invalid requests can be accepted. Changing the fallback to null-coalescing will fix every case. Also, the adapter has a SQL injection vulnerability.”

Investigate each claim independently. There is no SQL call in the provided adapter or service. A real SQL injection finding would need a reachable sink and an unsafe data flow; do not repeat the claim without them.

For the proposed fix, remember that the contract treats null as invalid. A null-coalescing fallback can still turn it into one. Ask whether the recommendation fixes the entire input contract, not just the first reproduction.

Exercise

Create this log in Org or plain text:

HypothesisInputExpectedObservedVerdict
Zero is silently defaulted
Null is silently defaulted
Null-coalescing fixes everything
SQL injection is reachable

Run the supplied smoke test. Explain why its green result does not address the invalid-input cases. Add a local regression test for at least two different rejected inputs.

Hint: omission is a distinct condition

Python’s baseline get supplies its default only when the key is missing. The TypeScript baseline explicitly checks key presence. Neither uses the value’s truthiness to decide whether it was supplied.

Checkpoint

You can identify which claims are confirmed, which are unsupported, and why the suggested fix is incomplete. Write one concise review comment supported by concrete input/output evidence.

Compare with the answer key. Save your tests and evidence log, then continue to regression tests.

← 3. Understand the change before hunting bugs · 5. Turn a suspicion into a meaningful regression test →