fix(rc-entitlement-drift-check): use REVENUECAT_SECRET_API_KEY_V2#66
Conversation
RC v1 secret keys are rejected by the v2 customer/entitlement endpoints with a 403. Splitting the env var so delete-account keeps using its v1 key on /v1/subscribers and rc-entitlement-drift-check uses a separately issued v2 key with customer_information:customers:read and customer_information:entitlements:read scopes. Surfaced during the first manual smoke test of the cron job (PR #60); returned 500 with rc_list_entitlements_403 in the function logs. Docs updated (payments.md, edge-functions.md, deployment.md) so operators issue a separate v2 key during first-time setup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 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 (4)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (3)**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,js}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
supabase/functions/**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (2)📚 Learning: 2026-03-12T20:10:29.256ZApplied to files:
📚 Learning: 2026-03-18T13:36:07.355ZApplied to files:
🔇 Additional comments (4)
📝 WalkthroughWalkthroughThis PR introduces a RevenueCat API secret key split for the rc-entitlement-drift-check edge function. The function now reads a v2-scoped key with specific customer information permissions, while the delete-account function retains the v1 key. All three documentation guides are updated to clarify the distinction and provide setup instructions. ChangesRevenueCat Secret Key Separation
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Follow-up to #60.
Summary
The drift check was failing first contact with the RC v2 API:
rc_list_entitlements_403. Cause: the v1 secret key reused fromdelete-accountisn't accepted by RC v2 endpoints.Splits the env var so each function uses the API key its endpoints expect:
delete-accountcontinues usingREVENUECAT_SECRET_API_KEY(v1) against/v1/subscribers/{id}.rc-entitlement-drift-checknow readsREVENUECAT_SECRET_API_KEY_V2(v2-scoped) for/v2/projects/.../customersand/v2/projects/.../entitlements.Docs updated (
payments.md,edge-functions.md,deployment.md) so the first-time setup instructs operators to issue a separate v2 key withcustomer_information:customers:read+customer_information:entitlements:readscopes.Test plan
After merging:
supabase secrets set REVENUECAT_SECRET_API_KEY_V2="<new-v2-key>".supabase functions deploy rc-entitlement-drift-check --no-verify-jwt.docs/payments.md→ "Drift Health Check" → first-time setup step 5. Expectstatus_code: 200and adrift_check_completeheartbeat in function logs.REVENUECAT_SECRET_API_KEYis left untouched —delete-accountkeeps working.Follow-up
None.
Summary by CodeRabbit
Documentation
Chores