Skip to content

Conversation

@marcindobry
Copy link
Contributor

@marcindobry marcindobry commented Dec 1, 2025

The existing usage of DEFAULT_RATE_LIMIT_PER_MIN env var had 2 issues

  • It didn't use zod, which is the standard way of parsing and using env vars in the codebase
  • It defaulted to 3500 if it's missing, which is a lot higher than our actual current base default.

This PR addresses both of these. The default value is set to 200, which is our current base default, but only for type-safety reasons. We make sure to set this value in all services and environments that would use this variable regardless.


Switch rate-limit default to zod-parsed env & lower fallback value

Replaces direct process.env access with typed retrieval via envs object and adjusts the fallback value of DEFAULT_RATE_LIMIT_PER_MIN from 3500 to 200. Keeps rate-limiter logic unchanged otherwise and aligns with the codebase’s standard zod-based env parsing.

Key Changes

• Removed inline parsing of process.env['DEFAULT_RATE_LIMIT_PER_MIN'] in packages/server/lib/middleware/ratelimit.middleware.ts
• Added envs.DEFAULT_RATE_LIMIT_PER_MIN import and usage
• Updated zod schema in packages/utils/lib/environment/parse.ts to .default(200) instead of leaving undefined or defaulting in code

Affected Areas

packages/server/lib/middleware/ratelimit.middleware.ts
packages/utils/lib/environment/parse.ts


This summary was automatically generated by @propel-code-bot

@marcindobry marcindobry force-pushed the marcin/use-zod-default-rate-limit-per-min branch from 1f77c59 to 494d1c7 Compare December 1, 2025 15:47
@marcindobry marcindobry marked this pull request as ready for review December 1, 2025 15:54
@marcindobry marcindobry requested a review from a team December 1, 2025 15:54
Copy link
Collaborator

@TBonnin TBonnin left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@kaposke kaposke left a comment

Choose a reason for hiding this comment

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

First PR? 😎

@marcindobry marcindobry added this pull request to the merge queue Dec 2, 2025
Merged via the queue into master with commit b50590d Dec 2, 2025
25 checks passed
@marcindobry marcindobry deleted the marcin/use-zod-default-rate-limit-per-min branch December 2, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants