Registry Mirror
Skip to content

Server: validate rateLimit.windowMs before creating the limiter #452

Closed

Description

@ashutoshpalhare

Which part?

@chatcops/server — packages/server/src/handler.ts

What happened?

createChatHandler validates rateLimit.maxRequests but passes rateLimit.windowMs to createRateLimiter without equivalent validation. Zero, negative, NaN, or infinite window values should not be silently accepted.

Expected behavior

Reject a rateLimit.windowMs that is not a finite number greater than zero, with a clear startup error.

Tests

  • windowMs: 0 and negative values throw.
  • NaN and Infinity are rejected.
  • Valid positive finite values and the default remain supported.

Activity

  1. anurag629 commented on Oct 29, 2026

    @anurag629
    Member

    Yours, @ashutoshpalhare. One correction to the report: windowMs of 0 or below already throws, from createRateLimiter in packages/core/src/limits/rate-limit.ts:60 (windowMs must be greater than 0). What gets through is NaN and Infinity, because NaN <= 0 is false. The same goes for limit/maxRequests (packages/server/src/handler.ts:83).

    So fix it in core: make rate-limit.ts:59-60 check Number.isFinite(x) && x > 0 for both limit and windowMs, and add the cases from your issue to packages/core/tests/limits/rate-limit.test.ts. If you also want the server to say which option is wrong (rateLimit.windowMs rather than windowMs), add that check at handler.ts:83, with a test in packages/server/tests/storage-config.test.ts or handler.test.ts. Patch changesets for @chatcops/core (and @chatcops/server if you touch it).

  2. anurag629 commented on Nov 11, 2026

    @anurag629
    Member

    @ashutoshpalhare it's been five days since my review on #581 without an update, so I'm opening this one up again. That's the usual rule in CONTRIBUTING.md, not a judgment. The code in #581 is right, only the description is missing (Closes #452, "How I tested this" and "AI assistance"). If you're still on it, fill those in and comment here, and we'll sort it out.

  3. self-assigned this
    on Nov 11, 2026
  4. bhushan4work commented on Nov 11, 2026

    @bhushan4work
    Collaborator

    as this is open again , I ll take this from here. will raise a pr shortly

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions