Closed dleehr closed 5 years ago
The 404 error is raised after the requests.put
on line 32.
This may be an authentication error. I know in many cases GitHub returns 404 when you're not authenticated/authorized correctly.
Further data on the 404 - unauthenticated curl GET and PUT for an existing file:
$ curl -X GET https://api.github.com/repos/Duke-GCB/helmod/contents/rpmbuild/SPECS/ddsclient-2.1.0-gcb01.spec | head
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17150 100 { 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
17 "name": "ddsclient-2.1.0-gcb01.spec",
1 "path": "rpmbuild/SPECS/ddsclient-2.1.0-gcb01.spec",
5 "sha": "7080a0f692a4cae65d2b94a10c6a00946d4e7c9b",
0 "size": 11693,
"url": "https://api.github.com/repos/Duke-GCB/helmod/contents/rpmbuild/SPECS/ddsclient-2.1.0-gcb01.spec?ref=master",
"html_url": "https://github.com/Duke-GCB/helmod/blob/master/rpmbuild/SPECS/ddsclient-2.1.0-gcb01.spec",
"git_url": "https://api.github.com/repos/Duke-GCB/helmod/git/blobs/7080a0f692a4cae65d2b94a10c6a00946d4e7c9b",
"download_url": "https://raw.githubusercontent.com/Duke-GCB/helmod/master/rpmbuild/SPECS/ddsclient-2.1.0-gcb01.spec",
0 "type": "file",
0 93715 0 --:--:-- --:--:-- --:--:-- 93715
$ curl -X PUT https://api.github.com/repos/Duke-GCB/helmod/contents/rpmbuild/SPECS/ddsclient-2.1.0-gcb01.spec
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3/repos/contents/#update-a-file"
}
$
Tried to debug a little inside CircleCI.
The token appears to be valid and the code structured to authorize should be correct. Even with a valid token, this returns a 404.
Since this is creating a new resource, I'd suggest it would be a POST
, but GitHub's documentation suggests it should be a PUT
I tried to reproduce locally with a new repo and the following script. After getting the URL right, no problem creating files.
#!/usr/bin/env python
import requests
import base64
url = 'https://api.github.com/repos/dleehr/putit/contents/api-file3/afile.txt'
commit_token = 'REMOVED'
data = {
"message": 'hello',
"committer": {"name": 'Dan Leehr', "email": 'dan.leehr@duke.edu'},
"content": 'aGVsbG8K',
"branch": 'master'
}
headers = { "Authorization": "token {}".format(commit_token)}
resp = requests.put(url, headers=headers, json=data)
print(resp.json())
resp.raise_for_status()
Looks like this issue was two fold.
Github docs about unexpected (to me at least) 404: https://developer.github.com/v3/troubleshooting/#why-am-i-getting-a-404-error-on-a-repository-that-exists
I released version 2.1.1 from master a few minutes ago, and the CircleCI build fails as below
See https://circleci.com/gh/Duke-GCB/DukeDSClient/34