sigmavirus24 / github3.py

Hi, I'm a library for interacting with GItHub's REST API in a convenient and ergonomic way. I work on Python 3.6+.
https://github3.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.21k stars 404 forks source link

Listing a repositories issues using state & milestone id is broken #406

Closed sigmavirus24 closed 6 years ago

sigmavirus24 commented 9 years ago
>>> r = g.repository('rcbops', 'rpc-openstack')
>>> list(r.issues(state='closed', milestone=1061934))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ian7708/virtualenv/tmp-d96e3bcf9b73726f/lib/python2.7/site-packages/github3/structs.py", line 68, in __iter__
    json = self._get_json(response)
  File "/Users/ian7708/virtualenv/tmp-d96e3bcf9b73726f/lib/python2.7/site-packages/github3/structs.py", line 96, in _get_json
    return self._json(response, 200)
  File "/Users/ian7708/virtualenv/tmp-d96e3bcf9b73726f/lib/python2.7/site-packages/github3/models.py", line 153, in _json
    if self._boolean(response, status_code, 404) and response.content:
  File "/Users/ian7708/virtualenv/tmp-d96e3bcf9b73726f/lib/python2.7/site-packages/github3/models.py", line 174, in _boolean
    raise error_for(response)
github3.exceptions.UnprocessableEntity: 422 Validation Failed
>>> list(r.issues(state='closed', milestone='1061934'))
[<Issue [rcbops/rpc-openstack #215]>, <Issue [rcbops/rpc-openstack #214]>, <Issue [rcbops/rpc-openstack #213]>, <Issue [rcbops/rpc-openstack #212]>, <Issue [rcbops/rpc-openstack #211]>, <Issue [rcbops/rpc-openstack #210]>, <Issue [rcbops/rpc-openstack #208]>, <Issue [rcbops/rpc-openstack #207]>, <Issue [rcbops/rpc-openstack #206]>, <Issue [rcbops/rpc-openstack #205]>, <Issue [rcbops/rpc-openstack #202]>, <Issue [rcbops/rpc-openstack #201]>, <Issue [rcbops/rpc-openstack #198]>, <Issue [rcbops/rpc-openstack #197]>, <Issue [rcbops/rpc-openstack #194]>, <Issue [rcbops/rpc-openstack #191]>, <Issue [rcbops/rpc-openstack #189]>, <Issue [rcbops/rpc-openstack #188]>, <Issue [rcbops/rpc-openstack #187]>, <Issue [rcbops/rpc-openstack #185]>, <Issue [rcbops/rpc-openstack #182]>, <Issue [rcbops/rpc-openstack #181]>, <Issue [rcbops/rpc-openstack #180]>, <Issue [rcbops/rpc-openstack #179]>, <Issue [rcbops/rpc-openstack #178]>, <Issue [rcbops/rpc-openstack #177]>, <Issue [rcbops/rpc-openstack #176]>, <Issue [rcbops/rpc-openstack #175]>, <Issue [rcbops/rpc-openstack #174]>, <Issue [rcbops/rpc-openstack #173]>, <Issue [rcbops/rpc-openstack #172]>, <Issue [rcbops/rpc-openstack #171]>, <Issue [rcbops/rpc-openstack #169]>, <Issue [rcbops/rpc-openstack #168]>, <Issue [rcbops/rpc-openstack #167]>, <Issue [rcbops/rpc-openstack #166]>, <Issue [rcbops/rpc-openstack #165]>, <Issue [rcbops/rpc-openstack #164]>, <Issue [rcbops/rpc-openstack #163]>, <Issue [rcbops/rpc-openstack #162]>, <Issue [rcbops/rpc-openstack #161]>, <Issue [rcbops/rpc-openstack #160]>, <Issue [rcbops/rpc-openstack #159]>, <Issue [rcbops/rpc-openstack #158]>, <Issue [rcbops/rpc-openstack #157]>, <Issue [rcbops/rpc-openstack #156]>, <Issue [rcbops/rpc-openstack #154]>, <Issue [rcbops/rpc-openstack #153]>, <Issue [rcbops/rpc-openstack #152]>, <Issue [rcbops/rpc-openstack #151]>, <Issue [rcbops/rpc-openstack #150]>, <Issue [rcbops/rpc-openstack #149]>, <Issue [rcbops/rpc-openstack #147]>, <Issue [rcbops/rpc-openstack #146]>, <Issue [rcbops/rpc-openstack #145]>, <Issue [rcbops/rpc-openstack #144]>, <Issue [rcbops/rpc-openstack #143]>, <Issue [rcbops/rpc-openstack #142]>, <Issue [rcbops/rpc-openstack #141]>, <Issue [rcbops/rpc-openstack #140]>, <Issue [rcbops/rpc-openstack #139]>, <Issue [rcbops/rpc-openstack #138]>, <Issue [rcbops/rpc-openstack #137]>, <Issue [rcbops/rpc-openstack #136]>, <Issue [rcbops/rpc-openstack #135]>, <Issue [rcbops/rpc-openstack #134]>, <Issue [rcbops/rpc-openstack #133]>, <Issue [rcbops/rpc-openstack #132]>, <Issue [rcbops/rpc-openstack #131]>, <Issue [rcbops/rpc-openstack #130]>, <Issue [rcbops/rpc-openstack #129]>, <Issue [rcbops/rpc-openstack #128]>, <Issue [rcbops/rpc-openstack #127]>, <Issue [rcbops/rpc-openstack #126]>, <Issue [rcbops/rpc-openstack #125]>, <Issue [rcbops/rpc-openstack #124]>, <Issue [rcbops/rpc-openstack #123]>, <Issue [rcbops/rpc-openstack #113]>, <Issue [rcbops/rpc-openstack #112]>, <Issue [rcbops/rpc-openstack #111]>, <Issue [rcbops/rpc-openstack #110]>, <Issue [rcbops/rpc-openstack #109]>, <Issue [rcbops/rpc-openstack #108]>, <Issue [rcbops/rpc-openstack #104]>, <Issue [rcbops/rpc-openstack #103]>, <Issue [rcbops/rpc-openstack #102]>, <Issue [rcbops/rpc-openstack #101]>, <Issue [rcbops/rpc-openstack #100]>, <Issue [rcbops/rpc-openstack #99]>, <Issue [rcbops/rpc-openstack #98]>, <Issue [rcbops/rpc-openstack #96]>, <Issue [rcbops/rpc-openstack #94]>, <Issue [rcbops/rpc-openstack #93]>, <Issue [rcbops/rpc-openstack #92]>, <Issue [rcbops/rpc-openstack #91]>, <Issue [rcbops/rpc-openstack #90]>, <Issue [rcbops/rpc-openstack #89]>, <Issue [rcbops/rpc-openstack #88]>, <Issue [rcbops/rpc-openstack #87]>, <Issue [rcbops/rpc-openstack #86]>, <Issue [rcbops/rpc-openstack #85]>, <Issue [rcbops/rpc-openstack #83]>, <Issue [rcbops/rpc-openstack #82]>, <Issue [rcbops/rpc-openstack #81]>, <Issue [rcbops/rpc-openstack #80]>, <Issue [rcbops/rpc-openstack #79]>, <Issue [rcbops/rpc-openstack #78]>, <Issue [rcbops/rpc-openstack #77]>, <Issue [rcbops/rpc-openstack #76]>, <Issue [rcbops/rpc-openstack #75]>, <Issue [rcbops/rpc-openstack #74]>, <Issue [rcbops/rpc-openstack #73]>, <Issue [rcbops/rpc-openstack #72]>, <Issue [rcbops/rpc-openstack #71]>, <Issue [rcbops/rpc-openstack #70]>, <Issue [rcbops/rpc-openstack #69]>, <Issue [rcbops/rpc-openstack #68]>, <Issue [rcbops/rpc-openstack #67]>, <Issue [rcbops/rpc-openstack #66]>, <Issue [rcbops/rpc-openstack #65]>, <Issue [rcbops/rpc-openstack #64]>, <Issue [rcbops/rpc-openstack #63]>, <Issue [rcbops/rpc-openstack #62]>, <Issue [rcbops/rpc-openstack #61]>, <Issue [rcbops/rpc-openstack #60]>, <Issue [rcbops/rpc-openstack #59]>, <Issue [rcbops/rpc-openstack #58]>, <Issue [rcbops/rpc-openstack #57]>, <Issue [rcbops/rpc-openstack #56]>, <Issue [rcbops/rpc-openstack #55]>, <Issue [rcbops/rpc-openstack #54]>, <Issue [rcbops/rpc-openstack #53]>, <Issue [rcbops/rpc-openstack #52]>, <Issue [rcbops/rpc-openstack #51]>, <Issue [rcbops/rpc-openstack #50]>, <Issue [rcbops/rpc-openstack #49]>, <Issue [rcbops/rpc-openstack #47]>, <Issue [rcbops/rpc-openstack #46]>, <Issue [rcbops/rpc-openstack #45]>, <Issue [rcbops/rpc-openstack #44]>, <Issue [rcbops/rpc-openstack #43]>, <Issue [rcbops/rpc-openstack #42]>, <Issue [rcbops/rpc-openstack #41]>, <Issue [rcbops/rpc-openstack #40]>, <Issue [rcbops/rpc-openstack #39]>, <Issue [rcbops/rpc-openstack #37]>, <Issue [rcbops/rpc-openstack #36]>, <Issue [rcbops/rpc-openstack #35]>, <Issue [rcbops/rpc-openstack #34]>, <Issue [rcbops/rpc-openstack #33]>, <Issue [rcbops/rpc-openstack #32]>, <Issue [rcbops/rpc-openstack #31]>, <Issue [rcbops/rpc-openstack #30]>, <Issue [rcbops/rpc-openstack #29]>, <Issue [rcbops/rpc-openstack #28]>, <Issue [rcbops/rpc-openstack #27]>, <Issue [rcbops/rpc-openstack #26]>, <Issue [rcbops/rpc-openstack #25]>, <Issue [rcbops/rpc-openstack #24]>, <Issue [rcbops/rpc-openstack #23]>, <Issue [rcbops/rpc-openstack #22]>, <Issue [rcbops/rpc-openstack #21]>, <Issue [rcbops/rpc-openstack #19]>, <Issue [rcbops/rpc-openstack #14]>, <Issue [rcbops/rpc-openstack #13]>, <Issue [rcbops/rpc-openstack #12]>, <Issue [rcbops/rpc-openstack #11]>, <Issue [rcbops/rpc-openstack #10]>, <Issue [rcbops/rpc-openstack #9]>, <Issue [rcbops/rpc-openstack #8]>, <Issue [rcbops/rpc-openstack #7]>, <Issue [rcbops/rpc-openstack #6]>, <Issue [rcbops/rpc-openstack #5]>, <Issue [rcbops/rpc-openstack #4]>, <Issue [rcbops/rpc-openstack #3]>, <Issue [rcbops/rpc-openstack #2]>, <Issue [rcbops/rpc-openstack #1]>]

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/23820437-listing-a-repositories-issues-using-state-milestone-id-is-broken?utm_campaign=plugin&utm_content=tracker%2F183477&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F183477&utm_medium=issues&utm_source=github).
sigmavirus24 commented 9 years ago

I think this is a problem with our 'Accept' header and this. If I just do

curl https://api.github.com/repos/rcbops/rpc-openstack/issues?per_page=100&state=closed&milestone=1061934

I get the results back that I expect. (That URL is generated by github3.py by doing

>>> i = r.issues(state='closed', milestone=1061934)
>>> next(i)
...
>>> i.last_response.request.url
sigmavirus24 commented 9 years ago

Ah that curl request was wrong. You need to quote the URL to avoid the & being interpreted the wrong way by your shell. (This is why zsh is better folks)

curl 'https://api.github.com/repos/rcbops/rpc-openstack/issues?per_page=100&state=closed&milestone=1061934'
{
  "message": "Validation Failed",
  "errors": [
    {
      "value": "1061934",
      "resource": "Issue",
      "field": "milestone",
      "code": "invalid"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/issues/#list-issues"
}
sigmavirus24 commented 9 years ago

Contacted GitHub support since this seems to be very clearly a problem with the API.

fn3d commented 6 years ago

@sigmavirus24 has this issue been resolved on Github's end? I am facing the same problem and was wondering whether this needs to be followed up again.

sigmavirus24 commented 6 years ago

Frankly @farhan3d I don't recall what the result of contacting GitHub support was. I ran into this over 3 years ago. Looking at the issue as I described it above, it looks like I'm using milestone.id rather than milestone.number. The API docs now describe the fact that it should be milestone.number. Perhaps you are also doing the wrong thing?