Repository navigation
fix: Reject an override snapshot that contains a deleted flag or segment - #404
Merged
kinyoklion merged 1 commit intoNov 20, 2026
Merged
Conversation
The override layer held a deleted item as given: a placeholder from DataKind.Deserialize for "deleted": true, or a definition marked as deleted. The overlay served it for its key, which hid the LaunchDarkly flag or segment from evaluation, from the flags that depend on it, and from the all-flags state. The sink now rejects such a snapshot as a whole, for every source, including a custom one: the layer keeps its contents, no change notification is sent, and an error naming the kind and key is logged. The layer itself refuses a deleted item. The file override source already fails a reload whose file has a deleted entry; tests now cover that the overrides in effect stay and that the log names the file and the entry. Spec: launchdarkly/sdk-specs#288, Requirements 1.1.1.1, 1.2.8.1, 1.3.6.2.
Member
Author
|
bugbot review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e1ef6a4. Configure here.
kinyoklion
marked this pull request as ready for review
November 10, 2026 19:02
kinyoklion
added a commit
to launchdarkly/sdk-test-harness
that referenced
this pull request
Nov 16, 2026
#599) <!-- TERMAG_PR_BODY_BEGIN --> ## Summary launchdarkly/sdk-specs#288 makes a flag or segment marked as deleted invalid in an override snapshot and in an override file: Requirements 1.1.1.1, 1.2.8.1 and 1.3.6.2. A file that contains one fails the reload in the same way as a malformed file, so the last good overrides stay in effect. Before this change, the SDKs did five different things with such an entry, and no contract test used one. The hot reload group of the flag overrides suite gains four tests, which run in both watching and polling mode: - **file with a deleted flag retains last good overrides** - **file with a deleted segment retains last good overrides** - **file with a deleted flag at startup supplies no overrides until it is corrected** - **file with a deleted segment at startup supplies no overrides until it is corrected** Each file that holds a deleted entry also changes the override of the evaluated flag. An SDK that dropped only the deleted entry, instead of discarding the reload, would serve the changed value and fail the test. The startup tests correct the file afterwards and wait for the correction to take effect. A source that stops after a failed initial load fails them. An entry with `"deleted": false` is an ordinary definition. Every full-flag override in the suite already carries that property, because the harness model serializes it, so no new test covers it. ## Results The `flag overrides` suite, run against each test service: | Test service | Result | |---|---| | go-server-sdk `v7` | all 8 new tests fail: the SDK applies the file and serves the changed value | | go-server-sdk launchdarkly/go-server-sdk#510 | 88 ran, all passed | | js-core launchdarkly/js-core#2187 | 73 ran, all passed | | java-core launchdarkly/java-core#259 | 48 ran, all passed (the test service has no listener capabilities) | | dotnet-core launchdarkly/dotnet-core#404 | 88 ran, all passed | | python-server-sdk launchdarkly/python-server-sdk#574, sync and async services | 88 ran on each, all passed | | ruby-server-sdk launchdarkly/ruby-server-sdk#493 | 88 ran, all passed | All 8 new tests ran on every service; none was skipped. **Related issues** - launchdarkly/sdk-specs#288 <!-- TERMAG_PR_BODY_END --> <!-- termag: box=i-0575d1c54853058d7 project=Overrides --> <sub>Opened from termag</sub> [SDK-3578](https://launchdarkly.atlassian.net/browse/SDK-3578) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Adds **hot reload contract tests** so override files that include a flag or segment with `"deleted": true` are treated like **malformed reloads**: the SDK must keep the last good overrides (or, at startup, serve **no** overrides until the file is fixed). > > The suite covers **deleted flags and deleted segments** under both **watching and polling** modes, using a new `docWithDeletedEntry` helper that pairs a changed `flagValues` entry with a deleted definition so partial application is detectable. > > After an invalid reload, tests confirm a subsequent valid file still applies normally. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cfe421d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> [SDK-3578]: https://launchdarkly.atlassian.net/browse/SDK-3578?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
tanderson-ld
approved these changes
Nov 20, 2026
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
Implements the "reject deleted entries" rule from launchdarkly/sdk-specs#288: Requirements 1.1.1.1 (the override store never holds a deleted item), 1.2.8.1 (the sink rejects a snapshot that contains one, as a whole, and logs it) and 1.3.6.2 (the file source fails a reload whose file has a deleted entry).
Describe the solution you've provided
Before: the override layer stored a deleted item as given. That could be a placeholder from
DataKind.Deserializefor"deleted": true, or a definition marked as deleted. The overlay then served it for its key. That hid the LaunchDarkly flag or segment from evaluation, from the flags that depend on it, and from the all-flags state, and listeners were notified of the change. Any source could do this, including a custom one through the publicIOverrideSink.After:
OverrideSink.SetOverrideschecks every snapshot first. If the snapshot contains a deleted flag or segment, the sink rejects the whole snapshot. The layer keeps its contents, no change notification is sent, and an error is logged that names the kind and the key, for exampleIgnoring an override snapshot because flag "x" is marked as deleted; .... The sink does not throw, and theIOverrideSinksignature is unchanged.OverrideLayer.SetAllalso refuses a deleted item (ArgumentException, layer unchanged), so the layer cannot hold one whichever caller reaches it.MarkedCopyno longer mentions placeholders.Unable to load flags: error parsing file: flag "x" is marked as deleted; remove the entry instead [<path>]. This PR adds tests for that behavior. Only the parser was covered before."deleted": falseis an ordinary definition and still loads.IOverrideSink.SetOverridesandFileOverrides.Source(). "Flag overrides are currently experimental and subject to change." is still on every public override API.Tests (replacing
MarkedCopyLeavesDeletedItemsAndOtherTypesAlone, which pinned the old behavior):OverrideSinkTest.RejectsASnapshotThatContainsADeletedItem: a theory over a deserialized deleted flag, a deserialized deleted segment, and a flag or segment object marked as deleted. In each case the layer is unchanged (same contents instance), the ordinary entries in the rejected snapshot are not applied, nothing is notified, nothing is thrown, the Error line names the kind and key, and the next valid snapshot applies. There is also a variant with no listeners, andAcceptsDefinitionsThatAreNotDeleted.OverrideLayerTest:FindDeletedItemReportsTheKindAndKey,FindDeletedItemAcceptsDefinitionsThatAreNotDeletedandSetAllRefusesADeletedItemAndKeepsItsContents.LdClientOverridesTest.SnapshotWithADeletedFlagIsRejected: a custom source supplies a deleted LaunchDarkly flag through the public sink. The previous override stays, the LaunchDarkly flag is still evaluated and is still in the all-flags state, and no flag change event fires.FileOverrideSourceTest.ReloadWithADeletedEntryFailsAndKeepsTheOverridesInEffect: covers a deleted flag and a deleted segment. No snapshot reaches the sink, the Error line names the file and the entry, and removing the entry recovers. AlsoInitialFileWithADeletedEntryLeavesTheLayerEmptyandEntriesWithDeletedFalseLoad.LdClientFileOverridesTest.EditThatAddsADeletedEntryKeepsTheOverridesInEffect: end to end. After the failed edit the client still serves the previous override and the LaunchDarkly flag. Once the entry is removed, the rest of the edit applies.How I ran them (in
pkgs/sdk/server):TESTFRAMEWORK=net8.0 BUILDFRAMEWORKS=net8.0 dotnet test -m:1 test/LaunchDarkly.ServerSdk.Tests.csproj --filteron theInternal.OverridesandInternal.FileLoadingnamespaces plusLdClientOverridesTestandLdClientFileOverridesTest: 237 passed, 0 failed.dotnet build -m:1 src/LaunchDarkly.ServerSdk.csprojfor all target frameworks: 0 errors, no new warnings.SetAlltests and the client-level custom-source test fail there. The file source tests pass there, as expected, because they cover parser behavior that already exists on this branch.Describe alternatives you've considered
IOverrideSink.SetOverrides. The sink does not throw for any other input, and the spec allows reporting through the log alone.Additional context
#394 touches
FileOverrides.csandFileOverrideSourceTest.csnear these changes. A trial merge of the two branches is clean.Opened from termag
SDK-3578
Note
Overview
Rejects override snapshots that include deleted flags or segments instead of storing them and hiding LaunchDarkly data for those keys.
OverrideSink.SetOverridesscans each snapshot with newOverrideLayer.FindDeletedItemlogic; if any entry is a deleted placeholder or has"deleted": true, the entire snapshot is dropped, existing overrides stay in place, listeners are not notified, and an error is logged (e.g.flag "x" is marked as deleted).OverrideLayer.SetAllthrowsArgumentExceptionon the same condition as a backstop. Entries with"deleted": falsestill load normally.Public docs on
IOverrideSink.SetOverridesand file overrides note this behavior; file sources already failed parses with deleted entries—tests now cover that path plus client-level custom sources and end-to-end file edits.Reviewed by Cursor Bugbot for commit e1ef6a4. Bugbot is set up for automated code reviews on this repo. Configure here.