Code Review3 min read

Code Review Interview Questions and Exercises

Realistic code review interview scenarios covering N+1 queries, race conditions, memory leaks, unhandled promises, authorization bugs, and weak TypeScript design.

Pairlet Team•Published: •Updated:

Code review exercises provide immediate signal on how candidates inspect code for bugs, edge cases, and architectural flaws. Here are realistic code review interview scenarios with guidance for interviewers.

Scenario 1: Database N+1 Query Anti-Pattern

JAVASCRIPT
// Flawed Pull Request:
async function getUsersWithOrders(userIds) {
  const users = [];
  for (const id of userIds) {
    const user = await db.query('SELECT * FROM users WHERE id = $1', [id]);
    const orders = await db.query('SELECT * FROM orders WHERE user_id = $1', [id]);
    users.push({ ...user, orders });
  }
  return users;
}
  • •What to look for: Candidate identifies N+1 database roundtrips and refactors using SQL IN (...) clauses or batch JOIN queries.
  • •*Practice N+1 Queries on Pairlet.*

Scenario 2: Swallowed Async Exceptions

JAVASCRIPT
// Flawed Pull Request:
async function processPayment(payment) {
  try {
    await stripe.charges.create(payment);
    await auditLogger.log(payment.id);
  } catch (err) {
    console.log("Something went wrong");
    return true; // Returns success despite failure!
  }
}
  • •What to look for: Candidate catches the silent error swallowing and false positive return value.
  • •*Practice Async Error Handling on Pairlet.*

Scenario 3: Node.js Memory Leak via Global Listeners

Scenario 4: Authorization Bypass in a Document API

Ask the candidate to review a document-sharing endpoint that checks whether a document exists but does not verify that the current user may access it.

  • •What to look for: The candidate distinguishes resource existence from resource ownership and explains the risk of an insecure direct object reference.
  • •What to ask next: “Where should authorization live, and what would you log without exposing sensitive data?”
  • •*Practice Authorization & Security Bug on Pairlet.*

Scenario 5: Unrestricted Concurrency in a Batch Job

Give the candidate a dispatcher that starts thousands of requests with an unbounded concurrency level.

  • •What to look for: The candidate identifies resource exhaustion, rate limits, back-pressure, and the need for a deliberate failure policy.
  • •What to ask next: “What is the smallest safe change that preserves the business requirement?”
  • •*Practice Promise Concurrency Exhaustion on Pairlet.*

How to Score the Review

Use the same rubric for every candidate:

  1. Correctness: Does the candidate identify behavior that can fail or lose data?
  2. Risk prioritization: Do they separate blockers from suggestions and explain the impact?
  3. Design judgment: Can they propose a focused change without over-engineering it?
  4. Communication: Do they ask clarifying questions and give actionable feedback?

A candidate does not need to find every planted flaw to show strong signal. A clear, well-reasoned prioritization is more useful than a long list of guesses.

Interviewer Prompt Sequence

  1. “What is this change supposed to accomplish?”
  2. “What would you verify before editing anything?”
  3. “Which finding has the highest impact?”
  4. “What is the smallest safe fix?”
  5. “How would you test that the fix works?”
  6. “What would you automate for the next review?”

Practice Code Review Exercises Live

Run live code review interview loops with candidates in a collaborative workspace. Browse all code review exercises or create a Pairlet Interview Room.

Frequently Asked Questions

What categories of bugs work best in code review exercises?

Database performance (N+1 queries), Async error swallowing, Authorization checking bypasses, Node.js memory leaks, and Unrestricted Promise concurrency.

How many intentional flaws should a code review exercise contain?

Use a small number of meaningful flaws, usually three to five, and make sure at least one is a correctness or security issue. The goal is to observe prioritization and reasoning, not to test whether someone can spot every planted detail.

Should the candidate fix every issue they find?

No. Ask them to rank the findings, explain the risk, and implement one focused fix. That keeps the exercise realistic and gives the interviewer a clear signal about trade-offs.

Practice Relevant Coding Problems
Practice Live Coding

Conduct Live Coding Interviews in the Browser

No candidate sign-up required. Create a room, share the link, and code together in real time with shared code execution.

Related Articles