{"thread":{"id":"64756","subject":"[PATCH] http-backend: write newlines to stderr when responding with errors","startedAt":"2026-01-08T22:59:37Z","lastAt":"2026-01-12T01:47:34Z","messageCount":4,"participants":["KJ Tsanaktsidis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"533305","messageId":"20260108225926.3587282-1-kj@kjtsanaktsidis.id.au","threadId":"64756","inReplyTo":null,"subject":"[PATCH] http-backend: write newlines to stderr when responding with errors","fromName":"KJ Tsanaktsidis","fromEmail":"kj@kjtsanaktsidis.id.au","sentAt":"2026-01-08T22:59:21Z","receivedAt":"2026-01-08T22:59:37Z","isPatch":true,"sender":{"key":"kj@kjtsanaktsidis.id.au","avatar":"https://avatars.githubusercontent.com/u/1418177?v=4"},"body":"From: KJ Tsanaktsidis <kjtsanaktsidis@groq.com>\n\nThe not_found and forbidden methods currently do not write a newline to\nstderr after the error message. This means that if git-http-backend is\ninvoked through something like fcgiwrap, and the stderr of that fcgiwrap\nprocess is sent to a logging daemon (e.g. journald), the error messages\nof several git-http-backend invocations will just get strung together,\ne.g.\n\n> Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'\n\nI think it's git-http-backend's responsibility to format these messages\nproperly, rather than it being fcgiwrap's job to notice that the script\ndidn't terminate stderr with a newline and do so itself.\n\nSigned-off-by: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>\n---\n http-backend.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/http-backend.c b/http-backend.c\nindex 52f0483dd3..bda8bb91e1 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -143,8 +143,10 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)\n \tend_headers(hdr);\n \n \tva_start(params, err);\n-\tif (err && *err)\n+\tif (err && *err) {\n \t\tvfprintf(stderr, err, params);\n+\t\tfprintf(stderr, \"\\n\");\n+\t}\n \tva_end(params);\n \texit(0);\n }\n@@ -159,8 +161,10 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)\n \tend_headers(hdr);\n \n \tva_start(params, err);\n-\tif (err && *err)\n+\tif (err && *err) {\n \t\tvfprintf(stderr, err, params);\n+\t\tfprintf(stderr, \"\\n\");\n+\t}\n \tva_end(params);\n \texit(0);\n }\n-- \n2.51.2\n\n"},{"id":"533537","messageId":"xmqqpl7govl8.fsf@gitster.g","threadId":"64756","inReplyTo":"20260108225926.3587282-1-kj@kjtsanaktsidis.id.au","subject":"Re: [PATCH] http-backend: write newlines to stderr when responding with errors","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-11T18:25:23Z","receivedAt":"2026-01-11T18:25:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au> writes:\n\n> From: KJ Tsanaktsidis <kjtsanaktsidis@groq.com>\n>\n> The not_found and forbidden methods currently do not write a newline to\n> stderr after the error message. This means that if git-http-backend is\n> invoked through something like fcgiwrap, and the stderr of that fcgiwrap\n> process is sent to a logging daemon (e.g. journald), the error messages\n> of several git-http-backend invocations will just get strung together,\n> e.g.\n>\n>> Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'\n>\n> I think it's git-http-backend's responsibility to format these messages\n> properly, rather than it being fcgiwrap's job to notice that the script\n> didn't terminate stderr with a newline and do so itself.\n\nNow another question is which between the callers and these two\nhelper functions is responsible to ensure that the message\nterminates with LF.  As these functions can be called only once, I\nthink letting them add LF makes sense (if they can be called twice\nor more, we can imagine that a caller may find it useful to make two\ncalls to produce a single log entry by ending only the later call\nwith LF, but such a use-case clearly cannot be supported with these\nNORETURN functions).  So I think this design makes sense.\n\n> Signed-off-by: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>\n> ---\n>  http-backend.c | 8 ++++++--\n>  1 file changed, 6 insertions(+), 2 deletions(-)\n>\n> diff --git a/http-backend.c b/http-backend.c\n> index 52f0483dd3..bda8bb91e1 100644\n> --- a/http-backend.c\n> +++ b/http-backend.c\n> @@ -143,8 +143,10 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)\n>  \tend_headers(hdr);\n>  \n>  \tva_start(params, err);\n> -\tif (err && *err)\n> +\tif (err && *err) {\n>  \t\tvfprintf(stderr, err, params);\n> +\t\tfprintf(stderr, \"\\n\");\n\nSomehow it feels overly heavyweight to call fprintf() just to send a\nsingle literal byte to the standard error stream.  putc('\\n', stderr)\nperhaps?  The same comment forr the other hunk.\n\n> +\t}\n>  \tva_end(params);\n>  \texit(0);\n>  }\n> @@ -159,8 +161,10 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)\n>  \tend_headers(hdr);\n>  \n>  \tva_start(params, err);\n> -\tif (err && *err)\n> +\tif (err && *err) {\n>  \t\tvfprintf(stderr, err, params);\n> +\t\tfprintf(stderr, \"\\n\");\n> +\t}\n>  \tva_end(params);\n>  \texit(0);\n>  }\n"},{"id":"533548","messageId":"20260112014508.17248-1-kj@kjtsanaktsidis.id.au","threadId":"64756","inReplyTo":"xmqqpl7govl8.fsf@gitster.g","subject":"[PATCH v2] http-backend: write newlines to stderr when responding with errors","fromName":"KJ Tsanaktsidis","fromEmail":"kj@kjtsanaktsidis.id.au","sentAt":"2026-01-12T01:44:39Z","receivedAt":"2026-01-12T01:45:15Z","isPatch":true,"sender":{"key":"kj@kjtsanaktsidis.id.au","avatar":"https://avatars.githubusercontent.com/u/1418177?v=4"},"body":"The not_found and forbidden methods currently do not write a newline to\nstderr after the error message. This means that if git-http-backend is\ninvoked through something like fcgiwrap, and the stderr of that fcgiwrap\nprocess is sent to a logging daemon (e.g. journald), the error messages\nof several git-http-backend invocations will just get strung together,\ne.g.\n\n> Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'Not a git repository: '/var/lib/git/foo.git'\n\nI think it's git-http-backend's responsibility to format these messages\nproperly, rather than it being fcgiwrap's job to notice that the script\ndidn't terminate stderr with a newline and do so itself.\n\nSigned-off-by: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>\n---\n http-backend.c | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/http-backend.c b/http-backend.c\nindex 52f0483dd3..8c810cfcbd 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -143,8 +143,10 @@ static NORETURN void not_found(struct strbuf *hdr, const char *err, ...)\n \tend_headers(hdr);\n \n \tva_start(params, err);\n-\tif (err && *err)\n+\tif (err && *err) {\n \t\tvfprintf(stderr, err, params);\n+\t\tputc('\\n', stderr);\n+\t}\n \tva_end(params);\n \texit(0);\n }\n@@ -159,8 +161,10 @@ static NORETURN void forbidden(struct strbuf *hdr, const char *err, ...)\n \tend_headers(hdr);\n \n \tva_start(params, err);\n-\tif (err && *err)\n+\tif (err && *err) {\n \t\tvfprintf(stderr, err, params);\n+\t\tputc('\\n', stderr);\n+\t}\n \tva_end(params);\n \texit(0);\n }\n-- \n2.51.2\n\n"},{"id":"533549","messageId":"e9c21aba-fa06-4e4f-baf5-f11f13d9ac72@app.fastmail.com","threadId":"64756","inReplyTo":"xmqqpl7govl8.fsf@gitster.g","subject":"Re: [PATCH] http-backend: write newlines to stderr when responding with errors","fromName":"KJ Tsanaktsidis","fromEmail":"kj@kjtsanaktsidis.id.au","sentAt":"2026-01-12T01:47:12Z","receivedAt":"2026-01-12T01:47:34Z","isPatch":true,"sender":{"key":"kj@kjtsanaktsidis.id.au","avatar":"https://avatars.githubusercontent.com/u/1418177?v=4"},"body":"On Mon, Jan 12, 2026, at 5:25 AM, Junio C Hamano wrote:\n> Now another question is which between the callers and these two\n> helper functions is responsible to ensure that the message\n> terminates with LF.  As these functions can be called only once, I\n> think letting them add LF makes sense (if they can be called twice\n> or more, we can imagine that a caller may find it useful to make two\n> calls to produce a single log entry by ending only the later call\n> with LF, but such a use-case clearly cannot be supported with these\n> NORETURN functions).  So I think this design makes sense.\n\nAgreed, the code clearly can't log more messages at this point!\n\n> Somehow it feels overly heavyweight to call fprintf() just to send a\n> single literal byte to the standard error stream.  putc('\\n', stderr)\n> perhaps?  The same comment forr the other hunk.\n\nI sent a v2 to fix this (hopefully correctly, I haven't had a whole lot\nof experience sending patches to mailing lists with git-send-email :/)\n"}]}