Skip to content

fix: cache polling ETags only for accepted payloads - #515

Merged
keelerm84 merged 4 commits into
launchdarkly:mainfrom
pcbeingused33:fix/polling-etag-validation
Dec 1, 2026
Merged

keelerm84 merged 4 commits into
launchdarkly:mainfrom
pcbeingused33:fix/polling-etag-validation

Conversation

@pcbeingused33

@pcbeingused33 pcbeingused33 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Found while reviewing the polling requesters. There is no associated issue.

Describe the solution you've provided

Both polling requesters cached the ETag from an HTTP 200 response before converting its payload into a ChangeSet. If conversion failed, the next request could still send that ETag and receive a 304. The synchronizer then treated the poll as successful and could report the data source as valid without receiving usable flag data.

Cache the response ETag only after successful ChangeSet conversion. The regression test covers both protocols with a simulated server that returns 304 when the request sends the rejected payload's ETag. It checks that both poll attempts report an invalid payload.

On Ruby 4.0.9, the requester, payload parsing, and synchronizer specs ran 51 examples. Both regression cases failed before the fix, and all 51 examples passed afterward. RuboCop reported no offenses in the two changed files.

Additional context

AI assistance was used to prepare the patch and regression tests.


Note

Overview
Fixes incorrect ETag caching in both HTTP polling requesters (HTTPPollingRequester and HTTPFDv1PollingRequester). Previously, a 200 response’s ETag was stored as soon as the body was JSON-parsed, even when changeset conversion failed. The next poll could send If-None-Match for that bad payload, get a 304, and look successful without usable flag data.

The change defers @etag = etag until changeset_result.success?, so only accepted payloads drive revalidation. The prior ETag is retained after a rejected response, and responses with no ETag no longer leave a stale cached value from a failed parse path in the same way.

Adds shared RSpec coverage for both requester classes: revalidation with a good ETag, clearing ETag when a later accepted response has none, keeping the last good ETag after an invalid payload, and ensuring a rejected payload’s ETag is not used for If-None-Match (so a 304 cannot mask repeated invalid responses).

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

@pcbeingused33
pcbeingused33 requested a review from a team as a code owner December 1, 2026 09:31
…ut an ETag

An accepted 200 without an ETag header kept the previous ETag. If the
server later reverted to that ETag, the SDK got a 304 and kept the newer
data. The requesters now replace the ETag on every accepted 200, which
matches the legacy Requestor.
http 5 needs a body or a connection to build a response. JRuby resolves
http 5.3.1, so the new ETag specs failed there.
@keelerm84
keelerm84 merged commit c0d19d3 into launchdarkly:main Dec 1, 2026
14 of 15 checks passed
@keelerm84

Copy link
Copy Markdown
Member

Thank you @pcbeingused33! As always, we appreciate the contribution.

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.

2 participants