I wouldn't merge this yet. There are 3 bugs that will break things, 1 SQL injection, and 1 risk. The original code was correct before this change.
src/orders/service.ts
L15: 🔴 bug: the loop runs one step too far.i <= order.items.lengthreadsorder.items[length], which isundefined, so.pricethrows a TypeError on every call. Use<, or keep the originalreduce, which was correct and shorter.L22: 🔴 bug:awaitwas removed fromthis.coupons.find(code), socouponis now a Promise.coupon.expiresAtisundefinedandundefined < Date.now()isfalse, so the expiry check never fires and expired coupons are accepted.coupon.idis alsoundefined. Put theawaitback.L24: 🔴 bug: the update is fire-and-forget and.catch(() => {})hides any failure. Callers see success even when the coupon was never saved, and nothing is logged. Put backawait this.repo.update(...)and let errors reach the caller.L22-23: 🟡 risk: iffindreturns null for an unknown code,coupon.expiresAtthrows a TypeError instead of a clear error. Addif (!coupon) throw new Error("invalid coupon").
L28: 🔴 security: SQL injection in listOrders. userId is put straight into the SQL string. A value like ' OR '1'='1 returns every user's orders, and with stacked queries an attacker could change or delete data (CWE-89, OWASP A03). Even if userId comes from an auth token today, this function can't assume that, and a single caller passing a request param makes it exploitable. Use a parameterized query, e.g. this.db.query("SELECT * FROM orders WHERE user_id = $1", [userId]) (use whatever placeholder syntax your driver expects).
L28: 🔵 nit:SELECT *returns every column and will pick up any column added later. List the columns you need.L27: 🔵 nit: no return type, unlikegetOrderTotal. AddPromise<Order[]>.
Real run recorded with claude-code / claude-opus-5-5. Output is shown verbatim, unmodified.
하는 일
코드 리뷰 코멘트를 L<줄>: <문제>. <수정>. 형식으로 짧게 써서 Pull Request에 바로 붙여 넣을 수 있게 합니다.
작동 방식
- /caveman-review, "review this PR", "review the diff"로 실행됩니다.
- 지적 사항마다 한 줄로, 정확한 줄 번호와 백틱으로 감싼 심볼 이름, 구체적인 수정 방법을 씁니다. 필요하면 심각도 태그(🔴 버그, 🟡 위험, 🔵 사소한 지적, ❓ 질문)를 붙입니다.
- 얼버무리는 표현과 diff 내용 반복을 뺍니다. 보안 문제, 설계 이견, 새 팀원 온보딩 상황에서는 제대로 된 문단으로 씁니다.
이럴 때 좋습니다
diff나 Pull Request를 리뷰하면서 지적 사항을 빠르게 훑어보고 싶을 때.
알아 둘 점
코멘트만 작성합니다. 코드를 고치거나, 승인·변경 요청을 하거나, 린터를 실행하지 않습니다.
지시문만 담긴 파일입니다. 스크립트가 없고, 네트워크에 연결하지 않으며, 파일을 쓰지 않습니다. 패키지에는 원본 저장소의 README, LICENSE, NOTICE도 들어 있습니다. 리뷰 지적 사항은 모델이 만든 결과이니 게시하기 전에 확인하세요.