git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH 0/9] friendlier http error messages

From
Jeff King <peff@peff.net>
Date
Apr 5, 2013, 22:13 UTC
Message-ID
<20130405221331.GA21209@sigill.intra.peff.net>

The error messages that git generates for routine http problems can sometimes be a bit verbose or confusing. They also provide no opportunity for the server to communicate any free-form text, even though the server knows much better than the git client the reason for the error or what the next step to suggest to the user might be.

This series provides a channel for those messages, and does some general cleanup and reformatting of the error messages that git itself produces.

Here are some before-and-after examples with this series (apologies for the long lines, but they are part of the ugliness I want to address, so I am leaving them in).

The "remote:" bits are simulated in the output below, as I haven't yet updated GitHub's server side to produce more useful messages. So you can repeat the tests, but note that the text you get from the server will not be the same (e.g., our 404 currently just says "Repository not found" which is not all that helpful).

  [before]
  $ git ls-remote https://github.com/non/existent
  fatal: https://github.com/non/existent/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?
  [after]
  $ git ls-remote https://github.com/non/existent
  remote: The remote repository was not found, or you do not have
  remote: permission to access it.
  fatal: repository 'https://github.com/non/existent/' not found
  [before]
  $ GIT_SMART_HTTP=0 git ls-remote https://github.com/git/git.git
  error: The requested URL returned error: 403 Forbidden while accessing https://github.com/git/git.git/info/refs
  fatal: HTTP request failed
  [after]
  $ GIT_SMART_HTTP=0 git ls-remote https://github.com/git/git.git
  remote: Sorry, fetching via dumb http is forbidden.
  remote: Please upgrade your git client to v1.6.6 or greater
  remote: and make sure that smart-http is enabled.
  fatal: unable to access 'https://github.com/git/git.git/': The requested URL returned error: 403

I still really hate the length of the generic http message (which you can see in the final 403 example). The text "The requested URL returned error:" comes from curl, though there is actually an opportunity to munge it, as you will see in the patches. However, I was unable to come up with a shorter text that sounded any better.

Another option would be to just split it across lines with some indentation, like:

  fatal: The requested URL returned error: 403
    while accessing https://github.com/git/git.git
I'm open to suggestions.

There are a lot of little patches, as I tried to explain the rationale for each individual change (and it makes it easy to take or reject individual patches). If we do take them all, it may make sense to just squash patches 3-5.

  [1/9]: http: add HTTP_KEEP_ERROR option
  [2/9]: remote-curl: show server content on http errors
  [3/9]: remote-curl: let servers override http 404 advice
  [4/9]: remote-curl: always show friendlier 404 message
  [5/9]: remote-curl: consistently report repo url for http errors
  [6/9]: http: simplify http_error helper function
  [7/9]: http: re-word http error message
  [8/9]: remote-curl: die directly with http error messages
  [9/9]: http: drop http_error function
-Peff
Next: Jeff King
Message 1 of 10 in “friendlier http error messages”
  1. 0/9 friendlier http error messagesJeff King, Apr 5, 2013
  2. 1/9 http: add HTTP_KEEP_ERROR optionJeff King, Apr 5, 2013
  3. 2/9 remote-curl: show server content on http errorsJeff King, Apr 5, 2013
  4. 3/9 remote-curl: let servers override http 404 adviceJeff King, Apr 5, 2013
  5. 4/9 remote-curl: always show friendlier 404 messageJeff King, Apr 5, 2013
  6. 5/9 remote-curl: consistently report repo url for http errorsJeff King, Apr 5, 2013
  7. 6/9 http: simplify http_error helper functionJeff King, Apr 5, 2013
  8. 7/9 http: re-word http error messageJeff King, Apr 5, 2013
  9. 8/9 remote-curl: die directly with http error messagesJeff King, Apr 5, 2013
  10. 9/9 http: drop http_error functionJeff King, Apr 5, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.