Skip to content

fix: Stop reporting the data source as valid when the store rejects FDv2 data - #518

Merged
keelerm84 merged 2 commits into
mainfrom
mk/SDK-3786/fdv2-failed-apply-status
Dec 3, 2026
Merged

keelerm84 merged 2 commits into
mainfrom
mk/SDK-3786/fdv2-failed-apply-status

Conversation

@keelerm84

@keelerm84 keelerm84 commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

When the store could not apply an FDv2 changeset (for example, a flag that fails to decode), Store#apply logged the error and returned nothing. FDv2 then reported VALID and signalled readiness with no usable data. Store#apply now returns whether it applied the changeset, and FDv2 acts on that result.

Technical design decisions

  • A rejected initializer basis logs a warning, and FDv2 tries the next initializer without reporting VALID. This matches the Go SDK.
  • A rejected synchronizer update reports INTERRUPTED with STORE_ERROR, which is the kind Java reports for a failed apply. Go and Java still report VALID on this path after a failed apply.
  • Changeset listeners are no longer notified when the in-memory store rejects the data.
  • The polling ETag is still cached before the apply. Go, Java and Python all do the same, so this PR leaves it alone.
Details

Found while reviewing #515. Repro: the FDv1 body {"flags":{"f":{"key":"f","version":1,"rules":"x"}}} passes payload conversion, then fails to decode in the in-memory store.

Tests added: Store#apply return values for full, delta, no-op, decode failure and a persistent store failure (spec/impl/data_store/store_spec.rb), plus FDv2 initializer and synchronizer behavior on a rejected changeset (spec/impl/data_system/fdv2_datasystem_spec.rb). All of them failed before the fix.

Gates: bundle exec rspec spec and bundle exec rubocop pass. On this box, the Bundler autoload spec also fails on unmodified main because of the local gem setup.

Opened from termag


Note

Overview
Store#apply now returns a boolean instead of void: true when a full transfer, delta, or no-op changeset is applied; false when the in-memory store rejects data, persistence raises, or an exception is caught. set_basis and apply_delta propagate that outcome, and changeset listeners are only notified on success.

FDv2 uses that result so the client does not lie about data health: a rejected initializer basis logs a warning and falls through to the next initializer without marking VALID or setting the ready event; a rejected synchronizer update sets status to INTERRUPTED with STORE_ERROR instead of treating the source as valid. Environment ID and readiness are only updated when apply succeeds (or there is no changeset).

Specs cover apply return values (decode failures, persistent store errors, listener behavior) and FDv2 initializer/synchronizer paths when the store rejects a changeset.

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

…Dv2 data

Store#apply now returns whether the store applied the changeset. It no
longer notifies changeset listeners when the in-memory store rejects the
data.

When the store rejects a basis from an initializer, FDv2 logs a warning
and tries the next initializer. It does not report VALID or signal
readiness for that basis. When the store rejects a synchronizer update,
FDv2 reports INTERRUPTED with a STORE_ERROR instead of VALID, and does
not signal readiness.

Generated-by: termag
@keelerm84
keelerm84 marked this pull request as ready for review December 3, 2026 17:57
@keelerm84
keelerm84 requested a review from a team as a code owner December 3, 2026 17:57
@keelerm84
keelerm84 merged commit a676dbb into main Dec 3, 2026
8 of 9 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3786/fdv2-failed-apply-status branch December 3, 2026 17:57

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit dd0abad. Configure here.

true
rescue => e
@logger.error { "[LDClient] Couldn't apply changeset: #{e.message}" }
false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Persist failure treated as rejected data

Medium Severity

Store#apply returns false when the persistent store raises, even after the in-memory store has already accepted the changeset. FDv2 then treats that as a rejected payload: it can skip VALID, try the next initializer (overwriting good data), or mark the synchronizer INTERRUPTED and later fall back, even though evaluations already have the new data.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit dd0abad. Configure here.

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