Observability & Error Handling
Code Review: Poor Logging & Error Design
easyCode ReviewJS / TS
Problem Statement
Review the following checkout payment gateway integration. Identify security logging violations, swallowed errors, lack of contextual logging, and leaking internal database stack traces to clients.
Code under review
JAVASCRIPT• handler.js
Pairlet Snippet
// Checkout billing processor
async function processBillingCheckout(req, res) {
const { creditCardNumber, cvc, amount, userId } = req.body;
console.log(`Processing payment for user ${userId}: card=${creditCardNumber}, cvc=${cvc}`);
try {
const charge = await stripe.charges.create({ amount, card: creditCardNumber });
return res.json({ success: true, chargeId: charge.id });
} catch (err) {
return res.status(500).json({
error: "Billing failure",
debugStackTrace: err.stack,
rawError: JSON.stringify(err)
});
}
}
Read only. Write down what you would flag below, then compare with the reference notes.
JavaScript & TypeScript versions included
Run this as a live interviewPractice solo
Write down what you would flag in this code, then compare it with the reference notes.
Write your findings first, then check yourself against the notes.