Hello all, long time git user, 

I encountered an issue when using a git dependency in python poetry, and I 
got down all the way to the way the git client & github.com are 
communicating, which is interesting and I'm wondering if this is normal 
behavior, it definitely looks unintuitive to me.

Basically github.com, when specifying an inexistent repo (e.g., due to a 
typo in the project name) serves a HTTP 401 to the git client, while it 
serves a HTTP 404 to normal clients.

To replicate, try `git clone https://github.com/rienafairefr/flask_pika`
The repo doesn't exist (it should be flask-pika with a dash not an 
underscore...), and yet the git client (with v2.25.1 at least) wants our 
username for github.com
with GIT_CURL_VERBOSE:
```
Cloning into 'flask_pika'...
* Couldn't find host github.com in the .netrc file; using defaults
*   Trying 140.82.121.3:443...
* TCP_NODELAY set
* Connected to github.com (140.82.121.3) port 443 (#0)
* found 391 certificates in /etc/ssl/certs
* ALPN, offering h2
* ALPN, offering http/1.1
* SSL connection using TLS1.3 / ECDHE_RSA_AES_128_GCM_SHA256
*        server certificate verification OK
*        server certificate status verification SKIPPED
*        common name: github.com (matched)
*        server certificate expiration date OK
*        server certificate activation date OK
*        certificate public key: RSA
*        certificate version: #3
*        subject: C=US,ST=California,L=San Francisco,O=GitHub\, 
Inc.,CN=github.com
*        start date: Tue, 05 May 2020 00:00:00 GMT
*        expire date: Tue, 10 May 2022 12:00:00 GMT
*        issuer: C=US,O=DigiCert Inc,OU=www.digicert.com,CN=DigiCert SHA2 
High Assurance Server CA
* ALPN, server accepted to use http/1.1
> GET /rienafairefr/flask_pika/info/refs?service=git-upload-pack HTTP/1.1
Host: github.com
User-Agent: git/2.25.1
Accept: */*
Accept-Encoding: deflate, gzip, br
Accept-Language: en-US, *;q=0.9
Pragma: no-cache

* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Authorization Required
< Server: GitHub Babel 2.0
< Content-Type: text/plain
< Content-Length: 21
< WWW-Authenticate: Basic realm="GitHub"
< X-Frame-Options: DENY
< X-GitHub-Request-Id: C970:DCEC:6424D55:90F0755:5F895E20
< 
* Connection #0 to host github.com left intact
Username for 'https://github.com':
```
We got a http 401, whereas a regular client (here, httpie) on the exact 
same URL gets a 404:
```
GET /rienafairefr/flask_pika/info/refs?service=git-upload-pack HTTP/1.1
User-Agent: HTTPie/1.0.3
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Host: github.com

HTTP/1.1 404 Not Found
date: Fri, 16 Oct 2020 08:48:11 GMT
content-type: text/plain; charset=utf-8
server: GitHub.com
```

The fix is easy (fix the typo !), but there is something very unintuitive 
about a 401 returned on an inexistent resource, and I don't know where the 
error is (in the git protocol, or the server behind github.com git service, 
"babel 2.0"), and I'd love to get the perspective of git experts.
Best,
Matthieu

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/022e5269-5279-4ca6-9616-ab85a9c095ccn%40googlegroups.com.

Reply via email to