Skip to content

fix(tests): _rate_limiter singleton not reset in test teardown -- rate limit state leaks between tests #297

Closed

Description

@piyushmakhija28

Summary

_configure_settings teardown in tests/conftest.py at line ~272 resets _api_key_store but not the _rate_limiter singleton. Tests that monkeypatch get_rate_limiter or the _rate_limiter module-level variable leave the modified instance in place for subsequent tests, causing state leaks.

Fix

tests/conftest.py teardown: also reset the _rate_limiter singleton:
import backend.app.security.rate_limit as _rl_mod
_rl_mod._rate_limiter = None
Or call monkeypatch.setattr(_rl_mod, "_rate_limiter", None) in the fixture.

Impact

Rate-limiter state from one test leaks into subsequent tests, causing intermittent failures when window counts from a previous test affect the rate-limit check in a later test.

Activity

  1. added
    bugSomething isn't working
    priority: lowMinor correctness or invariant violation
    code-reviewFound via automated code review
    on Jun 21, 2026
  2. piyushmakhija28 commented on Jun 21, 2026

    @piyushmakhija28
    ContributorAuthor

    Fixed in PR #280 (Sprint R3/R4: fix(sprint-r3): root-cause fixes for all 39 bugs from code review round 3 + Sprint R4 round 4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode-reviewFound via automated code reviewpriority: lowMinor correctness or invariant violation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions