From: Junio C Hamano <gitster@pobox.com>
To: Toon Claes <toon@iotcl.com>
Cc: git@vger.kernel.org, Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v2 1/2] bundle-uri: drain remaining response on invalid bundle-uri lines
Date: Wed, 08 Jul 2026 14:13:43 -0700 [thread overview]
Message-ID: <xmqqtsq9qj5k.fsf@gitster.g> (raw)
In-Reply-To: <20260708-toon-bundle-uri-no-uri-v2-1-09a03d8db556@iotcl.com> (Toon Claes's message of "Wed, 08 Jul 2026 17:03:34 +0200")
Toon Claes <toon@iotcl.com> writes:
> With this, clone now continues successfully if invalid bundle-URI data
> was sent by the server. This is intentional, because since the inception
> of `transport_get_remote_bundle_uri()` in 0cfde740f0 (clone: request the
> 'bundle-uri' command when available, 2022-12-22) the return value of
> that function is ignored in `cmd_clone()` so the clone can continue
> without bundles.
I am on the fence.
Alternatively, we could terminate the connection immediately, given
that we are clearly dealing with a broken server.
It is one thing to successfully parse the server's response (e.g.,
'fetch the bundle from this address') but fail to follow its
direction because, for example, the resource is unreachable. Since
bundles are optional, ignoring the failure and continuing makes
complete sense.
But it feels different when we can't even parse what the server is
saying.
While a malformed bundle-URI payload is benign enough to ignore
today, future protocol extensions might introduce mandatory
data. Eventually, we will need a robust way to tell ignorable and
fatal errors apart so we can react appropriately. That
classification can wait for a future topic, however.
The patch looks good and matches what you designed well.
Thanks.
> Signed-off-by: Toon Claes <toon@iotcl.com>
> ---
> connect.c | 15 ++++++++++++---
> t/t5558-clone-bundle-uri.sh | 29 +++++++++++++++++++++++++++++
> 2 files changed, 41 insertions(+), 3 deletions(-)
>
> diff --git a/connect.c b/connect.c
> index 47e39d2a73..1d74c1eda2 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -517,7 +517,7 @@ static void send_capabilities(int fd_out, struct packet_reader *reader)
> int get_remote_bundle_uri(int fd_out, struct packet_reader *reader,
> struct bundle_list *bundles, int stateless_rpc)
> {
> - int line_nr = 1;
> + int line_nr = 1, err = 0;
>
> /* Assert bundle-uri support */
> ensure_server_supports_v2("bundle-uri");
> @@ -536,10 +536,19 @@ int get_remote_bundle_uri(int fd_out, struct packet_reader *reader,
> const char *line = reader->line;
> line_nr++;
>
> + /*
> + * Do not parse if an error was encountered, but
> + * continue draining the response so no stale data
> + * is left in the reader for subsequent protocol
> + * exchanges.
> + */
> + if (err)
> + continue;
> +
> if (!bundle_uri_parse_line(bundles, line))
> continue;
>
> - return error(_("error on bundle-uri response line %d: %s"),
> + err = error(_("error on bundle-uri response line %d: %s"),
> line_nr, line);
> }
>
> @@ -554,7 +563,7 @@ int get_remote_bundle_uri(int fd_out, struct packet_reader *reader,
> check_stateless_delimiter(stateless_rpc, reader,
> _("expected response end packet after ref listing"));
>
> - return 0;
> + return err;
> }
>
> struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
> diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh
> index 7a0943bd36..7cc8627e17 100755
> --- a/t/t5558-clone-bundle-uri.sh
> +++ b/t/t5558-clone-bundle-uri.sh
> @@ -1302,6 +1302,35 @@ test_expect_success 'bundles with newline in target path are rejected' '
> test_path_is_missing escape
> '
>
> +test_expect_success 'bundles advertised with missing URI' '
> + git clone --no-local --mirror clone-from \
> + "$HTTPD_DOCUMENT_ROOT_PATH/no-uri.git" &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/no-uri.git" config uploadpack.advertiseBundleURIs true &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/no-uri.git" config bundle.version 1 &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/no-uri.git" config bundle.mode all &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/no-uri.git" config bundle.bundle-1.creationToken 1 &&
> +
> + git -c transfer.bundleURI=true clone \
> + "$HTTPD_URL/smart/no-uri.git" target-no-uri 2>err &&
> + test_grep "bundle ${SQ}bundle-1${SQ} has no uri" err &&
> + test_grep ! "expected packfile" err
> +'
> +
> +test_expect_success 'bundles advertised with empty URI' '
> + git clone --no-local --mirror clone-from \
> + "$HTTPD_DOCUMENT_ROOT_PATH/empty-uri.git" &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/empty-uri.git" config uploadpack.advertiseBundleURIs true &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/empty-uri.git" config bundle.version 1 &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/empty-uri.git" config bundle.mode all &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/empty-uri.git" config bundle.bundle-1.uri "" &&
> + git -C "$HTTPD_DOCUMENT_ROOT_PATH/empty-uri.git" config bundle.bundle-1.creationToken 1 &&
> +
> + git -c transfer.bundleURI=true clone \
> + "$HTTPD_URL/smart/empty-uri.git" target-empty-uri 2>err &&
> + test_grep "bundle ${SQ}bundle-1${SQ} has no uri" err &&
> + test_grep ! "expected packfile" err
> +'
> +
> # Do not add tests here unless they use the HTTP server, as they will
> # not run unless the HTTP dependencies exist.
next prev parent reply other threads:[~2026-07-08 21:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 8:58 [PATCH] bundle-uri: drain remaining response on invalid bundle-uri lines Toon Claes
2026-04-08 10:04 ` Patrick Steinhardt
2026-04-08 17:49 ` Justin Tobler
2026-04-10 6:31 ` Patrick Steinhardt
2026-04-10 15:38 ` Justin Tobler
2026-06-24 7:49 ` Toon Claes
2026-07-08 15:03 ` [PATCH v2 0/2] Fix fatal error in git-clone(1) when reading empty bundle-URI Toon Claes
2026-07-08 15:03 ` [PATCH v2 1/2] bundle-uri: drain remaining response on invalid bundle-uri lines Toon Claes
2026-07-08 21:13 ` Junio C Hamano [this message]
2026-07-08 15:03 ` [PATCH v2 2/2] bundle-uri: stop sending invalid bundle configuration Toon Claes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqtsq9qj5k.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jltobler@gmail.com \
--cc=toon@iotcl.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox