https://pantsbuild.org/ logo
#development
Title
# development
h

happy-kitchen-89482

12/30/2022, 2:37 PM
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

hundreds-father-404

12/30/2022, 3:19 PM
what if you try running on another machine like a devbox?
h

happy-kitchen-89482

12/30/2022, 3:28 PM
Works from a devbox in AWS
WTAF
h

hundreds-father-404

12/30/2022, 3:31 PM
hehe not trolling, have you tried restarting your mac?
h

happy-kitchen-89482

12/30/2022, 3:52 PM
No, but worth a try
w

wide-midnight-78598

12/30/2022, 10:11 PM
h

happy-kitchen-89482

12/30/2022, 10:12 PM
Nope, no idea what it was about
h

hundreds-father-404

12/30/2022, 10:13 PM
restarting comp didn't help?
h

happy-kitchen-89482

12/30/2022, 10:14 PM
Haven't tried
w

wide-midnight-78598

12/30/2022, 10:14 PM
When in doubt,
rm -rf /
- solves all problems
w

witty-crayon-22786

01/03/2023, 6:07 PM
do you have invalid creds in a
~/.netrc
?
h

happy-kitchen-89482

01/03/2023, 6:17 PM
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

wide-midnight-78598

01/22/2023, 3:38 PM
By default, requests uses something like python-requests/version?
h

happy-kitchen-89482

01/22/2023, 3:38 PM
Server error message, again, is "Bad credentials"
w

wide-midnight-78598

01/22/2023, 3:39 PM
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

happy-kitchen-89482

01/22/2023, 3:42 PM
Curl uses
curl/version
as the user-agent
I very much doubt that is the issue
Yeah, it is something about my system
w

wide-midnight-78598

01/22/2023, 3:42 PM
So strange.
Linux or Mac?
h

happy-kitchen-89482

01/22/2023, 3:43 PM
Mac
w

wide-midnight-78598

01/22/2023, 3:43 PM
Ah right, m1... So odd
h

happy-kitchen-89482

01/22/2023, 3:44 PM
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

wide-midnight-78598

01/22/2023, 3:46 PM
Ah, you have a netrc setup for Github?
h

happy-kitchen-89482

01/22/2023, 3:46 PM
Apparently
😃 1
I guess it must be expired creds
w

wide-midnight-78598

01/22/2023, 3:47 PM
Might be a good note for Pants or Ptex for troubleshooting - super rare, super awkward 401 that isn't replicated by other people?
h

happy-kitchen-89482

01/22/2023, 3:49 PM
Yep, creds expired... Nothing to see here. PEBKAC.
😆 1