Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

validateSettings() doesn't validate rateLimits[].period — zero period silently degrades to a 1ms backoff hint

Đã đóng Phù hợp với người mới
#811 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu từ src/utils/settings-config.ts, nơi validateSettings() đã kiểm tra pow.periodMs > 0, và đọc kiểu RateLimit trong src/@types/settings.ts. Thêm một vòng lặp cạnh kiểm tra đó, duyệt qua từng mảng limits.*.rateLimits (cùng với limits.admin.loginRateLimits), và đẩy một vấn đề { path, message } khi period không lớn hơn 0. Hoàn thành khi period bằng 0 hoặc âm khiến xác thực khi khởi động thất bại, với đường dẫn được nêu trong vấn đề, và các kiểm thử cài đặt hiện có vẫn đều đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

validateSettings() (src/utils/settings-config.ts) enforces pow.periodMs > 0, but nothing validates period on any rateLimits[] entry. The RateLimit type (src/@types/settings.ts) declares period: number as required, so period: 0 passes type checks and startup validation without a word.

Since #807, a rejected request carries a retry-after hint computed as Math.max(1, Math.ceil(period)) ms. With period: 0 that emits a protocol-valid 1ms backoff — the misconfiguration is silently masked instead of failing loudly at startup. (It also degenerates the EWMA decay itself: λ = ln(2)/0, so prior activity decays to zero instantly and every event is judged in isolation.)

Affected arrays

All of these accept a RateLimit[] whose period is never validated:

  • limits.event.rateLimits
  • limits.message.rateLimits
  • limits.connection.rateLimits
  • limits.invoice.rateLimits
  • limits.admissionCheck.rateLimits
  • limits.invite.rateLimits
  • limits.admin.rateLimits and limits.admin.loginRateLimits

Suggested fix

In validateSettings(), next to the existing pow.periodMs check, iterate each rate-limit array and push a { path: 'limits.….rateLimits[i].period', message: 'period must be greater than 0' } issue when !(period > 0) — same style as the existing checks.


From Muse

Ngôn ngữ chính
TypeScript
Star
829
Fork
234
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
24

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cameri/nostream

Tất cả issue của cameri/nostream

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.