Repository navigation
fix: Pass the environment ID to hooks on the async client - #598
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
AsyncLDClient built EvaluationSeriesContext without environment_id, and the async data systems never recorded the X-LD-EnvID header. Mirror the sync implementation for FDv1 streaming, FDv1 polling and FDv2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hooks registered on
AsyncLDClientalways receiveenvironment_id=NoneinEvaluationSeriesContext, while the same hooks onLDClientreceive the ID reported by LaunchDarkly.Root cause
#484 added environment ID support to the sync path only.
AsyncLDClientbuilds the series context withoutenvironment_id, and the async data systems never record theX-LD-EnvIDresponse header.Solution
Mirrors the sync implementation:
AsyncDataSystemexposesenvironment_id, andAsyncLDClientpasses it to the series context.Startaction. FDv1 polling reads it from the response headers throughget_all_data_with_headers; externally provided requesters that only implementget_all_datakeep working.AsyncFDv2records it from successful initializer results andVALIDsynchronizer updates only.Existing async polling tests now mock
get_all_data_with_headers, since that is the method the processor calls on the built-in requester.Tests
New end-to-end tests for streaming and polling with a local HTTP server, plus
AsyncFDv2tests for initializer and synchronizer paths. They fail onmainand pass with this change. The unit suite (excluding database integrations),mypy,isortandpycodestylepass locally on a single Python version.Related issues
Follow-up to #484. Sync/async parity: this brings the
async_*siblings in line.Requirements
async_*siblings (or N/A)This change was prepared with AI assistance.
Note
Overview
Fixes async/sync parity so
AsyncLDClienthooks get the real LaunchDarkly environment ID inEvaluationSeriesContextinstead of alwaysNone.AsyncLDClientnow suppliesenvironment_idfrom the active data system when running evaluation hooks.AsyncDataSystem(FDv1 and FDv2) exposes that ID after the SDK learns it from LaunchDarkly.FDv1 streaming records
X-LD-EnvIDfrom SSE connect headers; FDv1 polling addsget_all_data_with_headerson the built-in requester and records the header on each poll, with a fallback for custom requesters that only implementget_all_data. FDv2 stores the ID from successful initializer results andVALIDsynchronizer updates only.New end-to-end tests cover streaming and polling hooks; FDv2 and polling unit tests were updated accordingly.
Reviewed by Cursor Bugbot for commit dc5b8e4. Bugbot is set up for automated code reviews on this repo. Configure here.