Repository navigation
App Store レビュー取得を Connect API に移行 - #6299
Conversation
Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughApp Store レビュー取得の実装を RSS フィードから App Store Connect API へ移行。ES256 JWT 生成モジュールを新規追加し、API パーサー・フェッチ・ページング・Discord 投稿・ジョブ本体をすべて更新。 ChangesApp Store Connect API 移行
Sequence Diagram(s)sequenceDiagram
participant Scheduler
participant runAppStoreReviewJob
participant createAppStoreConnectJwt
participant fetchReviewsPage as App Store Connect API
participant postToDiscord as Discord Webhook
participant KV
Scheduler->>runAppStoreReviewJob: 定期実行
runAppStoreReviewJob->>createAppStoreConnectJwt: APPSTORE_CONNECT_KEY (JSON)
createAppStoreConnectJwt-->>runAppStoreReviewJob: ES256 JWT
loop links.next がある間(最大5ページ)
runAppStoreReviewJob->>fetchReviewsPage: GET /customerReviews (Bearer JWT)
fetchReviewsPage-->>runAppStoreReviewJob: ApiResponse { data[], links.next }
end
runAppStoreReviewJob->>postToDiscord: reviews[], appId, webhookUrl
postToDiscord-->>runAppStoreReviewJob: posted: boolean
runAppStoreReviewJob->>KV: saveReviewState(lastUpdated, updatedIds)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@functions/src/scheduled/appStoreReviews.test.ts`:
- Around line 3-99: The test file is missing an afterEach hook that clears mocks
between tests, which violates the testing guidelines. Add an afterEach hook with
jest.clearAllMocks() inside the describe block for parseApiReviews to ensure
mocks are properly cleared and prevent test pollution when mocks are added to
this file in the future.
In `@functions/src/scheduled/appStoreReviews.ts`:
- Around line 58-68: The fetchReviewsPage function has a security vulnerability
where it accepts any URL and adds an Authorization header with the JWT token
without validating the URL origin. Since the URL parameter comes from external
API responses (specifically links.next from line 158), it could redirect to
malicious endpoints and leak the JWT token. Validate that the provided URL
belongs to Apple's App Store Connect domain (check that the URL origin matches
Apple's official App Store Connect API domain) before making the fetch request
with the Authorization header. Only proceed with the fetch if the URL origin
validation passes, otherwise throw an error to prevent token leakage.
- Around line 192-200: The issue is that `lastIds` is being populated with only
the first 5 item IDs from `all.slice(0, 5).map((x) => x.id)`, but `lastUpdated`
is set to the `newest` item's timestamp. When there are 6 or more reviews with
the same timestamp as the newest review, the IDs beyond the first 5 won't be
saved in `lastIds`, causing them to match the same `lastUpdated` timestamp again
on the next run and trigger duplicate notifications. Replace `all.slice(0,
5).map((x) => x.id)` with filtering logic that includes all IDs from items that
have the same `updated` timestamp as the `newest` item, not just the first 5
items.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 577d3f39-a83a-4c0e-aab4-e1ab2e65c5d9
📒 Files selected for processing (5)
functions/src/lib/apple/accessToken.tsfunctions/src/scheduled/appStoreReviews.test.tsfunctions/src/scheduled/appStoreReviews.tsfunctions/src/types.tsfunctions/wrangler.jsonc
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Fixes Applied SuccessfullyFixed 2 file(s) based on 3 CodeRabbit feedback item(s). Files modified:
Commit: The latest autofix changes are on the |
概要
App Store レビュー取得を RSS JSON フィードから App Store Connect API に移行する。
変更の種類
変更内容
functions/src/lib/apple/accessToken.tsを新規追加(JWT 生成)parseAppStoreJsonをparseApiReviewsに置き換え、API レスポンス形式に対応APPSTORE_CONNECT_KEY/APPSTORE_APP_IDを追加し、旧APPSTORE_REVIEW_FEED_URLを削除version/urlを除去しterritoryを追加テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
リリースノート