-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
The state parameter is being ignored when using client.issues() or client.list_issues() methods. Regardless of the state value passed ('open', 'closed', 'all'), the API only returns open issues.
Environment
- Octokit version: 8.0
- Ruby version: 2.7.8
- Rails version: 7.1.3
Steps to Reproduce
require 'octokit'
client = Octokit::Client.new(access_token: 'YOUR_TOKEN')
# Attempt 1: Using client.issues()
options = {
filter: 'assigned',
state: 'closed',
sort: 'created',
direction: 'desc',
per_page: 100
}
issues = client.issues(options)
puts "Returned #{issues.count} issues"
puts "States: #{issues.map(&:state).uniq.join(', ')}"
# Expected: Returns closed issues
# Actual: Returns only open issues
# Attempt 2: Using client.list_issues()
issues = client.list_issues(options)
puts "Returned #{issues.count} issues"
puts "States: #{issues.map(&:state).uniq.join(', ')}"
# Expected: Returns closed issues
# Actual: Returns only open issuesExpected Behavior
When calling client.issues(state: 'closed') or client.list_issues(state: 'closed'), the API should return closed issues.
When calling with state: 'all', it should return both open and closed issues.
Actual Behavior
Both client.issues() and client.list_issues() ignore the state parameter and always return only open issues, regardless of what value is passed.
Workaround
Using the raw HTTP GET method works correctly:
# This WORKS correctly
result = client.get('/user/issues', {
filter: 'assigned',
state: 'closed',
sort: 'created',
direction: 'desc',
per_page: 100
})
puts "Returned #{result.count} issues"
puts "States: #{result.map { |i| i[:state] }.uniq.join(', ')}"
# Correctly returns closed issuesLog Evidence
When using client.list_issues(state: 'closed'):
Calling GitHub API list_issues with state=closed, filter=assigned, sort=created, direction=desc
GitHub API returned 7 issues with states: open
The logs clearly show that state=closed is passed to the method, but all 7 returned issues have state: "open".
When using client.get('/user/issues', state: 'closed'):
Calling GitHub API GET /user/issues with state=closed, filter=assigned
GitHub API returned 7 issues
Issue states: closed
This correctly returns 7 closed issues.
Additional Context
The GitHub REST API endpoint documentation clearly states that the state parameter should be supported:
https://docs.github.com/en/rest/issues/issues#list-issues-assigned-to-the-authenticated-user
The issue appears to be with how the wrapper methods (issues() and list_issues()) are passing parameters to the actual API endpoint, while the raw get() method correctly passes all query parameters.
Proposed Solution
The client.issues() and client.list_issues() methods should correctly pass the state parameter to the GitHub API endpoint, similar to how client.get('/user/issues', params) does.
Versions
- Octokit version: 8.0
- Ruby version: 2.7.8
- Rails version: 7.1.3
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status