Skip to content

fix(rate-limiter): incorrectly applying to non-configured fields#2690

Merged
EmrysMyrddin merged 4 commits intographql-hive:mainfrom
Tolsee:fix/ts-rate-limiter
Sep 19, 2025
Merged

fix(rate-limiter): incorrectly applying to non-configured fields#2690
EmrysMyrddin merged 4 commits intographql-hive:mainfrom
Tolsee:fix/ts-rate-limiter

Conversation

@Tolsee
Copy link
Contributor

@Tolsee Tolsee commented Sep 19, 2025

Description

Fixed a bug where the rate limiter plugin was incorrectly applying rate limiting to GraphQL fields not configured in configByField. Fields that should be unlimited were getting rate limited with default error messages.

The root cause was that { ...(rateLimitDirective ?? fieldConfig) } creates an empty object {} when both values are undefined, which is truthy, causing rate limiting to be applied to all fields.

Fixes #2689

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

N/A - This is a backend logic fix with test coverage.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added regression test 'should not rate limit fields that are not in configByField'
  • Verified all existing rate limiter tests continue to pass
  • Tested that configured fields are properly rate limited
  • Tested that unconfigured fields are never rate limited

Test Environment:

  • OS: macOS
  • @envelop/rate-limiter: 8.1.0
  • NodeJS: 24.7.0

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Tolsee Tolsee changed the title fix(rate-limiter): Rate limiter incorrectly applying to unconfigured fields fix(rate-limiter): rate limiter incorrectly applying to non-configured fields Sep 19, 2025
@Tolsee Tolsee changed the title fix(rate-limiter): rate limiter incorrectly applying to non-configured fields fix(rate-limiter): incorrectly applying to non-configured fields Sep 19, 2025
@EmrysMyrddin
Copy link
Contributor

Great catch! Thank you very much for the fix!

I took the freedom to push a changeset to your branch so that I can release as quickly as possible.

@EmrysMyrddin EmrysMyrddin merged commit 8f709a7 into graphql-hive:main Sep 19, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Rate limiter incorrectly applying to unconfigured fields

2 participants