Skip to content

feat: Add environment ID support for hooks - #202

Draft
kinyoklion wants to merge 1 commit into
mainfrom
devin/1786661026-java-hook-environment-id
Draft

feat: Add environment ID support for hooks#202
kinyoklion wants to merge 1 commit into
mainfrom
devin/1786661026-java-hook-environment-id

Conversation

@kinyoklion

Copy link
Copy Markdown
Member

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Companion to the equivalent work in the other SDKs: launchdarkly/python-server-sdk#484, launchdarkly/cpp-sdks#594, launchdarkly/ruby-server-sdk#414.

Describe the solution you've provided

EvaluationSeriesContext gains an environmentId field, populated from the X-LD-EnvID response header LaunchDarkly sends on flag delivery responses.

The value is latched into DataSourceUpdatesImpl and read back per evaluation through a supplier given to EvaluatorWithHooks, so it reflects the current data system state:

new EvaluationSeriesContext(method, featureKey, context, defaultValue, environmentIdSupplier.get())

Capture points:

  • FDv1 polling: DefaultFeatureRequestor records the header after the response is confirmed successful; PollingProcessor reports it to the update sink.
  • FDv1 streaming: StreamProcessor reads it from the message event headers.
  • FDv2: change sets already carried the environment ID; DataSourceUpdatesImpl.apply now latches it, but only once the data has been applied to the store successfully.
  • FDv1 fallback under FDv2: DataSourceSynchronizerAdapter forwards the ID onto the change sets it synthesizes.

Only non-empty values are latched, so a missing/empty header or an error response never clears a previously reported ID, and nothing is exposed before a successful response. The contract test service reports environmentId and declares hook-environment-id.

Describe alternatives you've considered

Storing the ID as data store metadata (as dotnet-core does) — the change set already carries it here, so latching in the update sink keeps the existing architecture and covers FDv1, which has no change set.

Additional context

Verified against the released harnesses: hooks/evaluation/provides the environment ID passes on v2.39.0 (FDv1, default and polling) and v3.2.0-alpha.6 (FDv2). The repo's v3 contract test run is still pinned to v3.0.0-alpha.6, so it won't exercise the new test until that pin is bumped.

Track hooks are not implemented in this SDK, so TrackSeriesContext is unaffected.

Link to Devin session: https://app.devin.ai/sessions/bfe54128e2804a96bb100e6120e9a3ef
Requested by: @kinyoklion

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@kinyoklion kinyoklion self-assigned this Aug 13, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the devin-pr Label for PR's created using devin. label Aug 13, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devin-pr Label for PR's created using devin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant