From 6f01d52fdaec34e81faa958abc3a6e793ff50a8b Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Mon, 8 Jun 2026 09:17:50 -0400 Subject: [PATCH] fix: Cast X-LaunchDarkly-Event-Schema header to string The event schema version is an int, but guzzlehttp/guzzle 7.11 deprecates non-string request header values and guzzle 8.0 will reject them. Cast the value to a string so events continue to publish without a deprecation warning. Fixes #246 --- src/LaunchDarkly/Impl/Util.php | 2 +- tests/Impl/UtilTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/LaunchDarkly/Impl/Util.php b/src/LaunchDarkly/Impl/Util.php index 05649307..0cfcefa0 100644 --- a/src/LaunchDarkly/Impl/Util.php +++ b/src/LaunchDarkly/Impl/Util.php @@ -138,7 +138,7 @@ public static function defaultHeaders(string $sdkKey, array $options): array public static function eventHeaders(string $sdkKey, array $options): array { $headers = Util::defaultHeaders($sdkKey, $options); - $headers['X-LaunchDarkly-Event-Schema'] = EventPublisher::CURRENT_SCHEMA_VERSION; + $headers['X-LaunchDarkly-Event-Schema'] = (string) EventPublisher::CURRENT_SCHEMA_VERSION; // Only the presence of this header is important. We encode a string // value of 'true' to ensure it isn't dropped along the way. $headers['X-LaunchDarkly-Unsummarized'] = 'true'; diff --git a/tests/Impl/UtilTest.php b/tests/Impl/UtilTest.php index dd671246..640b0aa6 100644 --- a/tests/Impl/UtilTest.php +++ b/tests/Impl/UtilTest.php @@ -26,4 +26,16 @@ public function testNonTrivialSamplingRatio(): void $this->assertEquals(504, $counts); } + + public function testEventHeaderValuesAreStrings(): void + { + // guzzlehttp/guzzle 7.11+ deprecates non-string header values and + // guzzle 8.0 will reject them, so every event header value must be a + // string. See https://github.com/launchdarkly/php-server-sdk/issues/246 + $headers = Util::eventHeaders('sdk-key', []); + + foreach ($headers as $name => $value) { + $this->assertIsString($value, "header '$name' should be a string"); + } + } }