Repository navigation
fix: cache FDv2 polling ETags after parsing - #306
Open
pcbeingused33 wants to merge 1 commit into
Open
pcbeingused33 wants to merge 1 commit into
pcbeingused33 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Requirements
Related issues
Related fix in the Ruby SDK: launchdarkly/ruby-server-sdk#515
Describe the solution you've provided
FDv2 polling cached the ETag from a successful HTTP response before reading and parsing its body. If parsing failed, the next poll for the same URI could send the rejected payload's ETag and receive a 304, leaving the SDK on stale flag data.
Update the ETag cache after the payload parses successfully. The regression test sends malformed JSON with an ETag, then polls the same URI and checks that the rejected ETag is absent from the request and the valid response is parsed.
Describe alternatives you've considered
Clearing the cached ETag on a payload error would force a full response on the next poll. Delaying the cache update preserves the validator for the last successfully parsed response.
Additional context
The regression failed with the original requestor because the second poll sent
If-None-Match: invalid-etag. All 21 tests inDefaultFDv2RequestorTestpassed with the fix on Temurin 17, targeting Java 8.This change was prepared with AI assistance (Codex).
Note
Overview
FDv2 polling no longer stores response ETags until the body parses successfully as flag events.
Previously, a 200 with bad JSON could still cache the ETag, so the next poll might send
If-None-Matchand get 304 Not Modified, leaving the SDK on stale flag data. ETag updates now run only afterFDv2Event.parseEventsArraysucceeds.A new regression test (
invalidJsonDoesNotCacheEtag) asserts that a malformed JSON response with an ETag does not affect later polls and that a valid follow-up response is parsed normally.Reviewed by Cursor Bugbot for commit 401ee19. Bugbot is set up for automated code reviews on this repo. Configure here.