`git push` from command line fails — Sztabina Smart HTTP handler returns empty response (SZ-140)
rk@tigase.net opened 2 days ago

Description

Pushing to a Sztab git repository from the command line fails with:

XML error: no element found
error: no DAV locking support on http://git.sztab.local/git/<repo>.git/
fatal: git-http-push failed

Component

Sztabina

Root Cause

Sztabina's info/refs?service=git-receive-pack endpoint returns HTTP 200 with an empty body instead of the proper Smart HTTP pktline advertisement. Git interprets the empty response as Smart HTTP being unavailable and falls back to WebDAV push, which Sztabina does not support.

Impact

Developers cannot push to Sztab git repositories from the command line. UI-based workflows (branch creation, PR merge) are unaffected.

Workaround

None currently. Use Sztab UI for all git operations.

Steps to Reproduce

git clone http://git.sztab.local/git/<repo>.git
# make a commit
git push
  • rk@tigase.net commented 1 day ago
    rksuma@Ramakrishnans-MacBook-Pro sztab % git checkout -b bugfix/SZ-140-git-push-command-fails
    Switched to a new branch 'bugfix/SZ-140-git-push-command-fails'
    rksuma@Ramakrishnans-MacBook-Pro sztab % 
    
    
  • rk@tigase.net changed state to 'In Progress' 1 day ago
    Previous Value Current Value
    Open
    In Progress
  • rk@tigase.net commented 1 day ago

    I found that the root cause is the missing CGI environment variables required for git-http-backend (the CGI binary that handles Smart HTTP push/fetch) to function properly.

    git-http-backend requires three CGI environment variables to function correctly for push:

    • QUERY_STRING — carries service=git-receive-pack, telling the backend which protocol to advertise on info/refs
    • REQUEST_METHOD — needed for POST dispatch on the actual git-receive-pack call
    • CONTENT_TYPE — needed to parse the POST body during push

    Go's cgi.Handler auto-derives many CGI vars from the incoming request, but when you provide an explicit Env slice it can't reliably inject all three of the above. They were absent from the Env slice in GitHTTPHandler.ServeHTTP.

    Without QUERY_STRING, git-http-backend sees no service parameter on info/refs, produces no output, and returns an empty 200 body. Git interprets an empty Smart HTTP response as Smart HTTP being unavailable and falls back to legacy WebDAV push — which Sztabina doesn't implement — producing the no DAV locking support error.

    Fix: explicitly add QUERY_STRING, REQUEST_METHOD, and CONTENT_TYPE to the Env slice passed to cgi.Handler.

  • rk@tigase.net commented 1 day ago

    No, the fix above did not work, although that change was warranted. Still debugging...

  • rk@tigase.net commented 1 day ago

    I wasted 2 hours. I don't have a root cause - analysis in https://tigase.dev/sztab/~issues/140#IssueComment-131417 is wrong.

    Caddy logs show that git push is not even hitting caddy!

issue 1 of 1
Type
Bug
Priority
Major
Assignee
Version
1.10.0
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (2)
Reference
SZ-140
Please wait...
Page is in error, reload to recover