Repository navigation
Feat/fail fast env validation - #58
Conversation
|
Warning Review limit reached
More reviews will be available in 46 minutes and 42 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a ChangesEnvironment Variable Hardening
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 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 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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/api/src/lib/env.ts`:
- Line 10: The port configuration is accepting arbitrary string values from
process.env.PORT without validation. Modify the port assignment in the config
export to parse the PORT environment variable as an integer using parseInt with
radix 10, validate that the parsed result is a valid number and within
acceptable port range (1-65535), and fall back to 3000 if the environment
variable is missing or invalid. This ensures only properly formatted port
numbers are used for the server configuration.
🪄 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: ASSERTIVE
Plan: Pro Plus
Run ID: 70ee1810-929a-450f-9d9d-33f4b584f487
📒 Files selected for processing (3)
apps/api/src/lib/env.tspackages/ui/src/components/ui/sidebar.tsxturbo.json
📜 Review details
🔇 Additional comments (2)
apps/api/src/lib/env.ts (1)
1-7: LGTM!Also applies to: 11-25
turbo.json (1)
7-12: LGTM!
Summary
Adds a
requireEnvhelper that throws an informative error at boot timeif a required environment variable is missing, replacing insecure dummy
fallbacks that could silently weaken session security.
Changes Made
requireEnv(key)helper function inapps/api/src/lib/env.tsDATABASE_URL,BETTER_AUTH_SECRET,BETTER_AUTH_URLnow required — throws on missingPORTremains optional with default3000globalEnvinturbo.jsonTesting
DATABASE_URL="postgresql://dummy" bun turbo lintpasses with 0 errors, 0 warningsRelated Issues
Checklist
Release Notes
DATABASE_URL,BETTER_AUTH_SECRET,BETTER_AUTH_URL) must be explicitly configured, preventing the application from starting with insecure dummy placeholder valuesPORTretain their default values