Skip to content

linkapi.ts 코드래빗 경고 nitpick 해결#519

Open
Bangdayeon wants to merge 1 commit into
mainfrom
refactor/#497-linkapi-warning-nitpick
Open

linkapi.ts 코드래빗 경고 nitpick 해결#519
Bangdayeon wants to merge 1 commit into
mainfrom
refactor/#497-linkapi-warning-nitpick

Conversation

@Bangdayeon
Copy link
Copy Markdown
Member

관련 이슈

PR 설명

  • linkApi: in 연산자 대신 Object.prototype.hasOwnProperty.call로 키 검사
    (상속된 프로토타입 키 매칭 방지)
    • summary-status route: 검증 후 String(parsedId)로 정규화한 id를 업스트림
      요청에 사용 ("01", " 123 " 등 입력에서 라우팅·로깅·캐시 키 일관성 확보)
    • summary-status route: 모듈 레벨 엔드포인트 캐시의 런타임 인스턴스별
      동작·한계에 대한 주석 추가
    • AllLink: 폴링 effect에서 selectedLinkId를 ref로 참조하도록 정리 (값 변경
      시 인터벌 재생성 방지)

@Bangdayeon Bangdayeon self-assigned this Jun 3, 2026
@Bangdayeon Bangdayeon linked an issue Jun 3, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f04e8f90-ea5a-4136-8a79-e1d8c8e42d5a

📥 Commits

Reviewing files that changed from the base of the PR and between 4291ad8 and 2072a12.

📒 Files selected for processing (4)
  • src/apis/linkApi.ts
  • src/app/(route)/all-link/AllLink.tsx
  • src/app/api/links/[id]/summary-status/route.ts
  • src/lib/client/apiClient.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/app/(route)/all-link/AllLink.tsx
  • src/apis/linkApi.ts
  • src/app/api/links/[id]/summary-status/route.ts
  • src/lib/client/apiClient.ts

Walkthrough

이 PR은 요청 취소 신호(AbortSignal) 지원을 HTTP 클라이언트(clientApiClient)부터 링크 목록 API(fetchLinks)를 거쳐 UI 핸들러(AllLink.handleLoadMore)까지 전파합니다. 타임아웃과 외부 signal을 AbortSignal.any로 결합하여 둘 중 하나가 취소되면 요청이 중단됩니다. 동시에 요약 상태 엔드포인트의 경로 ID를 안전 정수 범위로 검증하고 정규화하여 업스트림 라우팅 일관성을 보장하며, 모듈 레벨 메모이제이션의 runtime 특성을 설명하는 주석을 추가합니다.

Possibly related issues

Possibly related PRs

  • Team-SoFa/linkiving#484: 요약 상태 BFF 응답 처리 및 AllLink 폴링 동작 변경이 이 PR의 AllLink signal 처리 및 summary-status 경로 변경과 직접 관련됩니다.
  • Team-SoFa/linkiving#402: fetchLinks API 구현이 clientApiClient 호출 기반으로 변경되어, 이 PR의 signal 전달 기능과 동일 계층에서 상호작용합니다.
  • Team-SoFa/linkiving#339: fetchLinks 함수 서명 변경을 다루므로 이 PR의 신호 매개변수 추가와 직접 충돌할 수 있습니다.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive PR이 #497 이슈의 주요 목표들을 대부분 구현했습니다: (1) isRawSummaryStatus에서 in 연산자를 Object.prototype.hasOwnProperty.call로 변경, (3) AllLink.tsx에서 selectedLinkId를 ref로 관리하여 interval 재생성 방지, (4) 모듈 캐시에 주석 추가, (5) String(parsedId) 정규화 적용. 다만 목표 (2) fetchLinkSummaryStatus status 분기 단순화와 목표 (6) SummarySection.tsx 아이콘 로직 조정은 구현되지 않았습니다. 이슈 #497의 목표 (2)와 (6)이 아직 구현되지 않았으므로, 해당 변경사항이 별도 PR로 계획 중인지 또는 이 PR 범위에 포함되어야 하는지 명확히 해야 합니다.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 코드래빗 경고 nitpick 해결이라는 주요 변경사항을 명확히 요약하고 있으며, 실제 변경 내용(linkApi.ts 관련 작업)과 일치합니다.
Description check ✅ Passed PR 설명이 필수 섹션(관련 이슈, PR 설명)을 모두 포함하고 있으며, 수정된 각 파일의 구체적인 변경 내용을 명확히 나열하고 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 #497 이슈의 nitpick 항목들과 직결되어 있으며, 범위 밖의 변경은 없습니다. clientApiClient의 signal 처리 개선도 fetchLinks 함수에 signal 파라미터 추가를 지원하기 위한 필수 변경으로 보입니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#497-linkapi-warning-nitpick

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5b92945 and 4291ad8.

📒 Files selected for processing (5)
  • src/apis/linkApi.ts
  • src/app/(route)/all-link/AllLink.tsx
  • src/app/api/links/[id]/summary-status/route.ts
  • src/hooks/useGetInfiniteLinks.ts
  • src/lib/client/apiClient.ts

@Seong-Myeong
Copy link
Copy Markdown
Contributor

주석이 많은데 주석이 코드에서 다 필요한 내용인가요?

@Bangdayeon
Copy link
Copy Markdown
Member Author

주석이 많은데 주석이 코드에서 다 필요한 내용인가요?

불필요하게 길게 작성되어 줄였습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[후속 작업] PR #484 코드 리뷰 Nitpick 사항 정리

2 participants