Bug 579676 - GitSmartHttpTools doesn't follow Smart HTTP protocol
Summary: GitSmartHttpTools doesn't follow Smart HTTP protocol
Status: CLOSED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 6.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 6.1.1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-12 08:00 EDT by Sven Selberg CLA
Modified: 2022-11-11 10:14 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Selberg CLA 2022-04-12 08:00:23 EDT
GitSmartHttpTools [1] always return HTTP-200[2] for 403, 404, 500 errors. 

HTTP Smart protocol[3]:
""" If there is no repository at $GIT_URL, or the resource pointed to by a location matching $GIT_URL does not exist, the server MUST NOT respond with 200 OK response. A server SHOULD respond with 404 Not Found, 410 Gone, or any other suitable HTTP status code which does not imply the resource exists as requested.

""" If there is a repository at $GIT_URL, but access is not currently permitted, the server MUST respond with the 403 Forbidden HTTP status code.

Uploaded a patch that should solve the issue:
https://git.eclipse.org/r/c/jgit/jgit/+/192677

[1] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/refs/heads/master/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java#140
[2] https://git.eclipse.org/r/plugins/gitiles/jgit/jgit/+/refs/heads/master/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/GitSmartHttpTools.java#251
[3] https://git-scm.com/docs/http-protocol#_general_request_processing
Comment 1 Sven Selberg CLA 2022-05-09 07:47:50 EDT
Technical spec for the git-smart-http protocol:
https://github.com/git/git/blob/master/Documentation/technical/http-protocol.txt
Comment 3 Andrey Loskutov CLA 2022-06-01 09:37:19 EDT
The test seem to fails pretty often in gerrit on master branch:

https://ci.eclipse.org/jgit/job/stable/job/jgit.gerrit-pipeline.java11/1339/consoleFull

https://ci.eclipse.org/jgit/job/stable/job/jgit.gerrit-pipeline.java11/1342/consoleFull

14:56:49  [ERROR] org.eclipse.jgit.http.test.SmartClientSmartServerTest.testInitialClone_Small[org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory protocol V0]  Time elapsed: 0.213 s  <<< FAILURE!
14:56:49  org.junit.ComparisonFailure: expected:<[GE]T> but was:<[POS]T>
14:56:49  	at org.eclipse.jgit.http.test.SmartClientSmartServerTest.testInitialClone_Small(SmartClientSmartServerTest.java:613)
14:56:49  

Please check if that is a test or code propagation (6.1 -> master) issue.
Comment 4 Sven Selberg CLA 2022-06-07 04:22:22 EDT
The test failures seems to be unrelated to this change.
The failure is caused by the test expecting the first request from getRequests() to be a GET request whereas it in fact is a POST request.

The change fixing this issue doesn't change the VERB in any request and the test did not fail at integration into 6.1 and merge to 6.2, master.
Comment 5 Sven Selberg CLA 2022-11-09 11:44:59 EST
The assumption that "Wants not valid" should result in a 400 HTTP response was not correct, since this is an internal git error that may be transient. The requested SHA-1 might exist but just wasn't available at call-time.