Code Room
Vibe codingMediumvc-g507
Subject Ai code reviewLevel Mid–Senior~16 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

An AI assistant wrote this AWS Lambda (Node.js) handler to build a per-request audit trail. It passed a single-invocation test. Identify the bug, when it bites in production, and how you'd catch it.

js
const auditLog = []; exports.handler = async (event) => {  const userId = event.requestContext.authorizer.userId;  auditLog.push({ userId, action: event.action, ts: Date.now() });   const result = await processAction(event);  // attach the running trail so the caller sees their history  return {    statusCode: 200,    body: JSON.stringify({ result, trail: auditLog }),  };};
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.