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

[PATCH v2 2/2] bundle-uri: stop sending invalid bundle configuration

From
Toon Claes <toon@iotcl.com>
Date
Jul 8, 2026, 15:03 UTC
Message-ID
<20260708-toon-bundle-uri-no-uri-v2-2-09a03d8db556@iotcl.com>
In-Reply-To
<20260708-toon-bundle-uri-no-uri-v2-0-09a03d8db556@iotcl.com>
From: Justin Tobler <jltobler@gmail.com>

When bundle-URI info is requested by the client, the server responds with all "bundle.*" config lines as key=value packet lines. On the client-side, the received bundle config packet lines are always expected to contain both a key and a value otherwise the client errors out during parsing. The server performs no validation of the read bundle configuration though which results in any misconfiguration on the server-side, such as bundle configuration with an empty value, being blindly sent to the client.

To avoid having the server transmit invalid configuration to clients, only send bundle configuration that has non-empty values.

This change makes bundle-URI information sent by the server syntactically correct, but semantically it still can be invalid. For example the server may end up sending `bundle.bundle-1.creationToken`, but be lacking a `bundle.bundle-1.uri` for that bundle. The `uri` is mandatory, thus the client cannot process this bundle and will error with the message:

    error: bundle 'bundle-1' has no uri

Fixing this would require a more complex solution, because bundles need to be validated as a whole and not line-by-line. This is considered outside the scope of this change.

Co-authored-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Toon Claes <toon@iotcl.com>
---
 bundle-uri.c                 |  8 ++++++--
 t/lib-bundle-uri-protocol.sh | 23 +++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/bundle-uri.c b/bundle-uri.c
index 3b2e347288..f956d3db7b 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -946,8 +946,12 @@ static int config_to_packet_line(const char *key, const char *value,
 {
 	struct packet_reader *writer = data;
 
-	if (starts_with(key, "bundle."))
-		packet_write_fmt(writer->fd, "%s=%s", key, value);
+	if (starts_with(key, "bundle.")) {
+		if (value && *value)
+			packet_write_fmt(writer->fd, "%s=%s", key, value);
+		else
+			warning(_("config '%s' has no value"), key);
+	}
 
 	return 0;
 }
diff --git a/t/lib-bundle-uri-protocol.sh b/t/lib-bundle-uri-protocol.sh
index de09b6b02e..e0e19715cd 100644
--- a/t/lib-bundle-uri-protocol.sh
+++ b/t/lib-bundle-uri-protocol.sh
@@ -214,3 +214,26 @@ test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol
 		>actual &&
 	test_cmp_config_output expect actual
 '
+
+test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol v2 with empty value" '
+	test_config -C "$BUNDLE_URI_PARENT" \
+		bundle.bundle1.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-1.bdl" &&
+	test_config -C "$BUNDLE_URI_PARENT" \
+		bundle.bundle2.uri "" &&
+
+	# The empty bundle.bundle2.uri value is invalid configuration and the
+	# server must not advertise it to the client.
+	cat >expect <<-EOF &&
+	[bundle]
+		version = 1
+		mode = all
+	[bundle "bundle1"]
+		uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-1.bdl
+	EOF
+
+	test-tool bundle-uri \
+		ls-remote \
+		"$BUNDLE_URI_REPO_URI" \
+		>actual &&
+	test_cmp_config_output expect actual
+'
-- 
2.53.0.1323.g189a785ab5
Previous: Junio C Hamano
Message 10 of 10 in “bundle-uri: drain remaining response on invalid bundle-uri lines”
  1. bundle-uri: drain remaining response on invalid bundle-uri linesToon Claes, Apr 8, 2026
  2. Patrick SteinhardtApr 8, 2026
  3. Justin ToblerApr 8, 2026
  4. Patrick SteinhardtApr 10, 2026
  5. Justin ToblerApr 10, 2026
  6. Toon ClaesJun 24, 2026
  7. 0/2 Fix fatal error in git-clone(1) when reading empty bundle-URIToon Claes, Jul 8, 2026
  8. 1/2 bundle-uri: drain remaining response on invalid bundle-uri linesToon Claes, Jul 8, 2026
  9. Junio C HamanoJul 8, 2026
  10. 2/2 bundle-uri: stop sending invalid bundle configurationToon Claes, Jul 8, 2026

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.