(SP: 1) [SHOP] make cart provider capability env reads runtime-safe#448
(SP: 1) [SHOP] make cart provider capability env reads runtime-safe#448liudmylasovetovs merged 2 commits intodevelopfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 50 minutes and 9 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request refactors environment variable resolution across payment provider configuration files by replacing direct Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/lib/env/stripe.ts`:
- Around line 37-38: The code narrows STRIPE_MODE with a TypeScript cast without
runtime validation; update getStripeEnv/readServerEnv usage so STRIPE_MODE is
validated at runtime before assigning to StripeEnv.mode: read the raw value from
readServerEnv('STRIPE_MODE'), trim/lowercase it, and only accept 'test' or
'live' (e.g., if (val === 'test' || val === 'live') use it), otherwise fall back
to the existing nodeEnv-based default; reference STRIPE_MODE, readServerEnv,
getStripeEnv, nonEmpty and ensure the runtime check happens prior to any casting
to 'test' | 'live'.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f25ea5a0-5804-42a0-a073-19963cb0b527
📒 Files selected for processing (5)
frontend/app/[locale]/shop/cart/capabilities.tsfrontend/lib/env/monobank.tsfrontend/lib/env/provider-runtime.tsfrontend/lib/env/stripe.tsfrontend/lib/tests/shop/public-cart-env-contract.test.ts
Description
Fixes cart SSR regression and makes cart provider capability detection runtime-safe for Netlify.
Previously, the cart page depended on global shop env assertions and provider helpers that read
process.envdirectly. This caused:This PR:
readServerEnv()-compatible accessRelated Issue
Issue: #<issue_number>
Changes
readServerEnv()for Netlify/runtime-safe behaviorpublic-cart-env-contract) to avoidNODE_ENVreadonly mutationDatabase Changes (if applicable)
How Has This Been Tested?
Local verification:
psqlconnectivity verifiednpx vitest run lib/tests/shop/public-cart-env-contract.test.ts→ 10/10 tests passed/en/shop/cart/uk/shop/cart/pl/shop/cart→ all return
200 OKTest coverage confirms:
no SSR crash when critical env is missing
runtime-only env enables Stripe/Monobank correctly
invalid provider config fails closed (no false positives)
Checked responsive layout (if UI-related)
Tested accessibility (keyboard / screen reader)
Screenshots (if applicable)
N/A (server/runtime fix)
Checklist
Before submitting
Reviewers
Summary by CodeRabbit