Skip to content

Commit 51f9ec1

Browse files
committed
disallow empty string for baggage name
spec 1.36.0 clarifies that empty string is not a valid baggage name
1 parent 7eb3abb commit 51f9ec1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/API/Baggage/BaggageBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public function remove(string $key): BaggageBuilderInterface
2222
/** @inheritDoc */
2323
public function set(string $key, $value, ?MetadataInterface $metadata = null): BaggageBuilderInterface
2424
{
25+
if ($key === '') {
26+
return $this;
27+
}
2528
$metadata ??= Metadata::getEmpty();
2629

2730
$this->entries[$key] = new Entry($value, $metadata);

tests/Unit/API/Baggage/BaggageTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,11 @@ public function test_get_all(): void
125125
);
126126
}
127127

128+
public function test_empty_name_disallowed(): void
129+
{
130+
$baggage = Baggage::getBuilder()->set('', 'bar')->build();
131+
$this->assertTrue($baggage->isEmpty());
132+
}
133+
128134
// endregion
129135
}

0 commit comments

Comments
 (0)