Well this is some chaos, while trying to generate ...
# development
h
Well this is some chaos, while trying to generate a changelog for 2.14.1rc0:
1
Copy code
>>> import requests
>>> response = requests.get(f"<https://api.github.com/repos/pantsbuild/pants/pulls/17867>")
>>> response.status_code
401
But
Copy code
$ curl -s -o /dev/null -w "%{http_code}\n" <https://api.github.com/repos/pantsbuild/pants/pulls/17867>
200
And since the repo is public, it should never 401
And this has worked fine for me as recently as a few days ago
There has been no new release of requests (which is lockfiled in any case)
The error text from the server is "Bad credentials"
1
h
what if you try running on another machine like a devbox?
h
Works from a devbox in AWS
WTAF
h
hehe not trolling, have you tried restarting your mac?
h
No, but worth a try
w
h
Nope, no idea what it was about
h
restarting comp didn't help?
h
Haven't tried
w
When in doubt,
rm -rf /
- solves all problems
w
do you have invalid creds in a
~/.netrc
?
h
No, those were good
Seeing this again, with `ptex`:
Copy code
$ ptex <https://api.github.com/repos/pantsbuild/pants/git/refs/tags/release_2.15.0rc2>
Failed to fetch <https://api.github.com/repos/pantsbuild/pants/git/refs/tags/release_2.15.0rc2>: [22] HTTP response code said error (The requested URL returned error: 401)
Fails similarly with
requests
in a repl, but works with curl:
Copy code
$ curl -s -o /dev/null -w "%{http_code}\n"  <https://api.github.com/repos/pantsbuild/pants/git/refs/tags/release_2.15.0rc2>
200
Voodoo-rebooting my machine didn't help
Turning off VPN didn't help
scie-pants relies on ptex being able to fetch release tags, so this is a problem
Will look at what is different in the headers
request headers, that is
w
By default, requests uses something like python-requests/version?
h
Server error message, again, is "Bad credentials"
w
Not sure what curl uses by default, but I remember using requests and accidentally making a scraper for my own blog links got me kick-banned from half the internet until I changed my ID. Can you setup requests to emulate a browser's agent and see if that bypasses?
Should be a 403, instead of a 401 - so that's already weird
Also... ?
Copy code
>>> import requests
>>> requests.get("<https://api.github.com/repos/pantsbuild/pants/git/refs/tags/release_2.15.0rc2>")
<Response [200]>

>>> requests.get("<https://github.com/pantsbuild/pants/releases/download/release_2.15.0rc2/pants.2.15.0rc2.pex>")
<Response [200]>

>>> requests.utils.default_headers() 
{'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}
h
Curl uses
curl/version
as the user-agent
I very much doubt that is the issue
Yeah, it is something about my system
w
So strange.
Linux or Mac?
h
Mac
w
Ah right, m1... So odd
h
Oh, interesting
requests is sending a basic auth header
If I add that header to curl's request it also fails in the same way
OK, so this is because of my .netrc
w
Ah, you have a netrc setup for Github?
h
Apparently
😃 1
I guess it must be expired creds
w
Might be a good note for Pants or Ptex for troubleshooting - super rare, super awkward 401 that isn't replicated by other people?
h
Yep, creds expired... Nothing to see here. PEBKAC.
😆 1