linkapi.ts 코드래빗 경고 nitpick 해결#519
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
Walkthrough이 PR은 요청 취소 신호(AbortSignal) 지원을 HTTP 클라이언트( Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/api/links/[id]/summary-status/route.ts (1)
34-40:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win정수 ID 검증을 추가해 주세요.
현재 조건이면
1.5같은 소수와 정밀도 손실이 발생하는 큰 수가 통과해safeId가 의도와 다른 값으로 정규화될 수 있습니다. 업스트림에 다른 리소스를 조회할 수 있으니 정수/안전정수까지 검증하는 편이 안전합니다.제안 수정안
- if (!Number.isFinite(parsedId) || parsedId <= 0) { + if (!Number.isFinite(parsedId) || !Number.isInteger(parsedId) || !Number.isSafeInteger(parsedId) || parsedId <= 0) { return NextResponse.json({ success: false, message: 'Invalid id.' }, { status: 400 }); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/api/links/`[id]/summary-status/route.ts around lines 34 - 40, The current ID validation allows non-integer or out-of-range numeric values (e.g., 1.5 or huge numbers) to pass and then be normalized into unexpected safeId; update the check that uses parsedId so it requires an integer and a safe integer (use Number.isInteger(parsedId) and Number.isSafeInteger(parsedId)) in addition to the existing finite and >0 checks before producing safeId; locate the validation around parsedId and the safeId assignment and reject requests that fail the integer/safe-integer test so safeId remains a true positive integer string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/app/api/links/`[id]/summary-status/route.ts:
- Around line 34-40: The current ID validation allows non-integer or
out-of-range numeric values (e.g., 1.5 or huge numbers) to pass and then be
normalized into unexpected safeId; update the check that uses parsedId so it
requires an integer and a safe integer (use Number.isInteger(parsedId) and
Number.isSafeInteger(parsedId)) in addition to the existing finite and >0 checks
before producing safeId; locate the validation around parsedId and the safeId
assignment and reject requests that fail the integer/safe-integer test so safeId
remains a true positive integer string.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8f5b1c32-1e2e-4581-8a98-e6404b132056
📒 Files selected for processing (5)
src/apis/linkApi.tssrc/app/(route)/all-link/AllLink.tsxsrc/app/api/links/[id]/summary-status/route.tssrc/hooks/useGetInfiniteLinks.tssrc/lib/client/apiClient.ts
4291ad8 to
6186d61
Compare
|
주석이 많은데 주석이 코드에서 다 필요한 내용인가요? |
6186d61 to
2072a12
Compare
불필요하게 길게 작성되어 줄였습니다. |
관련 이슈
PR 설명
in연산자 대신Object.prototype.hasOwnProperty.call로 키 검사(상속된 프로토타입 키 매칭 방지)
String(parsedId)로 정규화한 id를 업스트림요청에 사용 (
"01"," 123 "등 입력에서 라우팅·로깅·캐시 키 일관성 확보)동작·한계에 대한 주석 추가
selectedLinkId를 ref로 참조하도록 정리 (값 변경시 인터벌 재생성 방지)