claude-code - ✅(Solved) Fix Bug: Sort/filter mismatch in auto-close-duplicates script causes missed issues [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52407Fetched 2026-04-24 06:08:00
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

In scripts/auto-close-duplicates.ts (lines 123-141), there is a mismatch between how issues are paginated and how they are filtered:

  • Issues are fetched from the API without specifying a sort parameter (defaults to sorting by updated time)
  • But the filtering logic checks created_at <= threeDaysAgo

This mismatch means:

  • An issue created 10 days ago but updated 1 hour ago will appear early in pagination
  • An issue created 2 days ago but not updated recently may not appear until later pages
  • This can cause the script to miss issues that should be processed or process them inefficiently

Root Cause

In scripts/auto-close-duplicates.ts (lines 123-141), there is a mismatch between how issues are paginated and how they are filtered:

  • Issues are fetched from the API without specifying a sort parameter (defaults to sorting by updated time)
  • But the filtering logic checks created_at <= threeDaysAgo

This mismatch means:

  • An issue created 10 days ago but updated 1 hour ago will appear early in pagination
  • An issue created 2 days ago but not updated recently may not appear until later pages
  • This can cause the script to miss issues that should be processed or process them inefficiently

Fix Action

Fixed

PR fix notes

PR #52417: fix: add explicit sort parameters to auto-close-duplicates query

Description (problem / solution / changelog)

Summary

  • Add explicit sort=created&direction=asc to the issues API query
  • Without this, the default sort (created DESC) returns newest issues first, and the script filters for issues older than 3 days — wasting API calls on recent issues that all get filtered out
  • With the 20-page safety limit (2000 issues), older eligible issues may never be reached in high-volume repos

Test plan

  • Verify the script still correctly identifies and closes duplicate issues
  • Verify older issues are processed first, reducing wasted API calls

Fixes #52407

🤖 Generated with Claude Code

Changed files

  • scripts/auto-close-duplicates.ts (modified, +1/-1)
RAW_BUFFERClick to expand / collapse

Description

In scripts/auto-close-duplicates.ts (lines 123-141), there is a mismatch between how issues are paginated and how they are filtered:

  • Issues are fetched from the API without specifying a sort parameter (defaults to sorting by updated time)
  • But the filtering logic checks created_at <= threeDaysAgo

This mismatch means:

  • An issue created 10 days ago but updated 1 hour ago will appear early in pagination
  • An issue created 2 days ago but not updated recently may not appear until later pages
  • This can cause the script to miss issues that should be processed or process them inefficiently

Expected Behavior

The sort parameter and the filter condition should be aligned — either:

  • Sort by created time explicitly and filter by created_at, or
  • Sort by updated time and filter by updated_at

Suggested Fix

Add sort=created to the API request to align with the created_at filter logic.

extent analysis

TL;DR

Add sort=created to the API request in scripts/auto-close-duplicates.ts to align the sort order with the filter logic.

Guidance

  • Review the API documentation to ensure sort=created is a valid parameter and understand its implications on the response.
  • Update the API request in scripts/auto-close-duplicates.ts to include the sort=created parameter, ensuring the sort order matches the filter condition.
  • Test the updated script to verify that issues are correctly paginated and filtered based on their creation time.
  • Consider adding logging or monitoring to detect any unexpected behavior or performance changes after implementing the fix.

Example

// Example API request update in scripts/auto-close-duplicates.ts
const response = await fetch(`https://api.example.com/issues?sort=created`);

Notes

This fix assumes that sorting by creation time is the desired behavior. If sorting by update time is preferred, the filter condition should be updated to use updated_at instead.

Recommendation

Apply workaround: Add sort=created to the API request, as it directly addresses the mismatch between the sort order and filter logic, ensuring that issues are processed efficiently and correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING