Merged PR role count can double-count when the current PR is outside the first search page

Đang mở Phù hợp với người mới
#108 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
76/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ệ
github, typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Tìm countMergedPrs và onPullRequest, sau đó đọc các bài kiểm thử hiện có cho kết quả tìm kiếm và trường hợp exceptUrl. Tái hiện sự cố với total_count: 101 và 100 mục không có PR hiện tại; đảm bảo số lượng trước đó loại trừ PR này ngay cả khi nó không xuất hiện trên trang đầu tiên. Hoàn tất khi webhook đánh giá ngưỡng vai trò bằng số lượng chính xác.

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

Mô tả

Bug

countMergedPrs requests only the first 100 GitHub search results, then uses total_count for the full result set. When called from the merged-PR webhook with exceptUrl, it subtracts one only if the current PR is present in those first 100 items.

For a linked contributor with more than 100 merged PRs, GitHub can include the just-merged PR in total_count but omit it from the first page. In that case countMergedPrs(..., pr.html_url) returns a count that already includes the current PR. onPullRequest then adds one again (earlier + 1), which can grant a contributor role one merge earlier than its configured threshold.

Reproduction

  1. Mock a GitHub search response with total_count: 101 and 100 items that do not include the current PR URL.
  2. Call countMergedPrs with exceptUrl set to that current PR URL.
  3. The function returns 101 instead of 100 because it cannot tell whether the omitted 101st result is the current PR.
  4. The webhook adds one and evaluates role tiers using 102.

Expected behavior

The webhook's earlier-PR count should exclude the current PR even when it is not on the first search page, so role thresholds are evaluated against an accurate count.

Ngôn ngữ chính
TypeScript
Star
0
Fork
1
Merge trung bình
2 giờ 38 phút
Pull request đã merge (30 ngày)
73

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 codercops/discord-bot

Tất cả issue của codercops/discord-bot

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.