Skip to content

feat: add X-LaunchDarkly-Instance-Id header (SDK-2355)#111

Open
keelerm84 wants to merge 3 commits into
mainfrom
mk/sdk-2355-instance-id
Open

feat: add X-LaunchDarkly-Instance-Id header (SDK-2355)#111
keelerm84 wants to merge 3 commits into
mainfrom
mk/sdk-2355-instance-id

Conversation

@keelerm84
Copy link
Copy Markdown
Member

@keelerm84 keelerm84 commented May 12, 2026

Summary

Adds the X-LaunchDarkly-Instance-Id header to every outbound polling, streaming, and event request. Value is a v4 UUID generated once per SDK instance (via Data.UUID.V4.nextRandom) and stamped into defaultRequestHeaders so it rides every channel through the existing HTTP-configuration layer.

Design note: module-cycle workaround

makeHttpConfiguration could not live inside HttpConfiguration.hs because Config.Internal transitively reaches back to HttpConfiguration via DataSource.Internal -> Config.ClientContext. A new internal module LaunchDarkly.Server.Config.HttpConfigurationInternal houses the function. clientVersion is passed in as a function argument from Client.hs rather than imported, to keep the cycle from re-forming. This is Haskell-specific scaffolding the other SDKs didn't need.

Test plan

  • stack test — 184 / 184 HUnit cases pass (178 baseline + 6 new)
  • fourmolu --mode check on src/ and test/ — clean
  • Contract-tests executable builds clean with "instance-id" capability registered
  • Contract tests were not executed locally — no sdk-test-harness instance available in this sandbox. CI will exercise the harness.
  • CI green

Note

Medium Risk
Adds a new automatically generated header to every polling/streaming/event HTTP request, which can affect network behavior and downstream logging/metrics. Low code volume, but touches shared HTTP configuration used across all request paths.

Overview
Adds automatic inclusion of X-LaunchDarkly-Instance-Id on all outbound SDK HTTP traffic by generating a UUIDv4 once per makeHttpConfiguration call and stamping it into defaultRequestHeaders.

Refactors makeHttpConfiguration into LaunchDarkly.Server.Client.Internal (and updates imports/call sites) so the shared HTTP configuration layer carries this identifier across polling, streaming, and event clients.

Updates contract-test capabilities to advertise instance-id, and adds a new HUnit spec (Spec.HttpConfiguration) to validate header presence, uniqueness, UUIDv4 format, and per-instance variability.

Reviewed by Cursor Bugbot for commit 28900f8. Bugbot is set up for automated code reviews on this repo. Configure here.

Generate a v4 UUID once per SDK instance in the HTTP configuration
builder and stamp it on defaultRequestHeaders. Because that header list
is shared by the polling, streaming, and event clients, every outbound
request carries the same stable per-instance identifier without
per-channel plumbing.

The builder lives in a new internal module
LaunchDarkly.Server.Config.HttpConfigurationInternal so it can pull from
Config.Internal without creating an import cycle through
Config.ClientContext / DataSource.Internal. The instance-id header name
and a thin makeInstanceIdHeader helper stay in
LaunchDarkly.Server.Config.HttpConfiguration so unit tests can exercise
the GUID generation directly.

Registers the "instance-id" capability with the contract-test service so
the cross-SDK harness can verify the header on stream, poll, and event
requests.
@keelerm84 keelerm84 requested a review from a team as a code owner May 12, 2026 21:05
keelerm84 added 2 commits May 12, 2026 17:42
Replace `x /= Nothing` with `isJust x` in two assertions in
Spec.HttpConfiguration, per hlint's "Use isJust" suggestion. The
quality-checks CI job runs hlint with `fail-on: warning` and was
failing on these two warnings.
…K-2355)

Moves makeHttpConfiguration into Client.Internal alongside clientVersion,
removing the Config/HttpConfigurationInternal module that existed only to
work around an import cycle. The instance-id header is generated inline
in makeHttpConfiguration rather than via a separate makeInstanceIdHeader
helper, so Config.HttpConfiguration is back to just the HttpConfiguration
type and prepareRequest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant