feat: Add the file-based override source - #529
Draft
kinyoklion wants to merge 3 commits into
Draft
kinyoklion wants to merge 3 commits into
kinyoklion wants to merge 3 commits into
Conversation
kinyoklion
force-pushed
the
rlamb/overrides-python-events
branch
from
September 28, 2026 20:29
042fce2 to
0e55650
Compare
kinyoklion
force-pushed
the
rlamb/overrides-python-file-source
branch
from
September 28, 2026 20:29
021778c to
2074b74
Compare
kinyoklion
force-pushed
the
rlamb/overrides-python-events
branch
from
September 30, 2026 20:31
0e55650 to
c79f244
Compare
kinyoklion
force-pushed
the
rlamb/overrides-python-file-source
branch
from
September 30, 2026 20:31
2074b74 to
1950d45
Compare
kinyoklion
force-pushed
the
rlamb/overrides-python-events
branch
from
October 1, 2026 23:43
c79f244 to
352d360
Compare
kinyoklion
force-pushed
the
rlamb/overrides-python-file-source
branch
from
October 1, 2026 23:43
1950d45 to
3e47045
Compare
Adds ldclient.integrations.overrides.FileOverrideSourceBuilder, the file-based override source described by the OVERRIDE specification. The source reads one or more JSON or YAML files in the file data source document format, with optional flags, flagValues, and segments members, and supplies each successful load to the SDK's override sink as a full snapshot. Files are combined in the configured order. The duplicate keys handling is fail by default, which rejects the reload and keeps the previously loaded overrides, or ignore, which keeps the first file's entry. A configured file that does not exist contributes no overrides, so a file can be created later and deleting a file removes its overrides. A file that exists but cannot be read or parsed fails that reload, the last good overrides stay in effect, the failure is logged, and the load is retried after a bounded delay and on the next detected change. Change detection is one of two modes: polling, the default, examines the files once per second by default with a one second minimum, and watching reacts to file system notifications through the watchdog package. Watching without the watchdog package and a builder with no paths are construction errors. The initial load completes during client construction. Every applied change is logged at Info level with the overrides in effect and what each configured file supplied.
…l of the file override source Change detection is set up before the initial load, so an edit made while the files are first read is picked up. Close stops the reloader even when the change detector fails to close. The builder rejects a poll interval that is not a number or not finite.
kinyoklion
force-pushed
the
rlamb/overrides-python-events
branch
from
October 3, 2026 01:18
352d360 to
9f4108c
Compare
kinyoklion
force-pushed
the
rlamb/overrides-python-file-source
branch
from
October 3, 2026 01:18
3e47045 to
cfb781a
Compare
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 cfb781a. Configure here.
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.
Summary
This is the fifth step of the flag overrides port described by the OVERRIDE specification. It is based on the events branch because the phases are stacked; retarget to
feat/overridesonce that branch merges.ldclient.integrations.overrides.FileOverrideSourceBuilderis the public entry point. It is passed todatasystem.ConfigBuilder.overrides(...)and builds an override source that reads one or more local files in the file data source document format (optionalflags,flagValues, andsegmentsmembers, JSON or YAML) and supplies each successful load to the SDK's override sink as a full snapshot.flagValuesentries expand into full flag definitions, so the layer holds only full entities; as the specification describes for a value-only override, the expansion is a flag that is on and serves its single variation as the fallthrough, so the evaluation reason kind isFALLTHROUGH. The existing file data sources keep their current behavior, including their ownflagValuesexpansion.Behavior:
duplicate_keys_handlingisfailby default, which rejects the reload and keeps the previously loaded overrides, orignore, which keeps the first configured file's entry.change_detectionis one of two alternatives.polling(the default) compares modification time and size on an interval, one second by default with a one second minimum; a lower interval is raised to the minimum with a warning, and a value that is not a finite number, or longer than the runtime can wait, is a construction error.watchinguses thewatchdogpackage and is a construction error when the package is not installed. Notifications are debounced so a burst from one edit produces one reload.start, which the data system calls during client construction, so an override present at startup takes effect from the first evaluation.Flag overrides in effect: 2 flags, 1 segment (/etc/ld/a.json: 2 flags, 1 segment; /etc/ld/b.json: absent), orFlag overrides: none in effect (...).change_detectionorduplicate_keys_handlingvalues raiseValueErrorwhen set. This is stricter than the Go builder, which treats an unrecognized duplicate keys handling asfail.The module is added to the API reference (
docs/api-integrations.rst) and every public docstring carries the experimental note.Tests cover the builder validation and defaults, synchronous initial load, YAML, multi-file order and duplicate handling, absent files appearing and disappearing, the Info log lines, both change detection modes, last-good retention across a malformed edit in both modes, the automatic retry with no change signal, close semantics, and an end-to-end run through
LDClientwhere a file is added, changed, and emptied while the client never receives LaunchDarkly data.SDK-3250
Note
Overview
Adds an experimental file-based flag override source so operators can force flag/segment values from local JSON or YAML without restarting the app or reaching LaunchDarkly. The public entry point is
FileOverrideSourceBuilder, wired throughdatasystem.ConfigBuilder.overrides(...).The source merges one or more files (same format as the file data source, including
flagValuesexpansion), applies full snapshots to the override sink, and reloads on file changes via polling (default, 1s minimum) or optional watchdog watching. Missing files contribute nothing; bad parses or duplicate keys (defaultfail) keep the last good snapshot and retry. Info logs summarize what is in effect per file. API docs coverldclient.integrations.overrides.Tests cover builder validation, merge/absent-file behavior, both change-detection modes, failure retention/retry, lifecycle/close, and an
LDClientflow where overrides are added, changed, and cleared live.Reviewed by Cursor Bugbot for commit cfb781a. Bugbot is set up for automated code reviews on this repo. Configure here.