Skip to content

feat: Add the file-based override source - #453

Draft
kinyoklion wants to merge 4 commits into
rlamb/overrides-ruby-eventsfrom
rlamb/overrides-ruby-file-source
Draft

kinyoklion wants to merge 4 commits into
rlamb/overrides-ruby-eventsfrom
rlamb/overrides-ruby-file-source

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

This PR is stacked on #452 because it supplies the override store that the earlier PRs add, and its client-level spec relies on the marked reasons and events they produce.

This change adds LaunchDarkly::Integrations::FileData.override_source, the file-based override source that the OVERRIDE specification defines. It is configured with LaunchDarkly::DataSystem::ConfigBuilder#overrides:

overrides = LaunchDarkly::Integrations::FileData.override_source(paths: ["/etc/launchdarkly/overrides.json"])
config = LaunchDarkly::Config.new(data_system: LaunchDarkly::DataSystem.default.overrides(overrides))

The source reads one or more JSON or YAML files in the file data source document format (flags, flagValues, segments) and supplies complete snapshots to the SDK's override store. Its options are paths (required, non-empty strings in precedence order), duplicate_keys_handling (:fail, the default, or :ignore, which keeps the first file's entry), change_detection (:polling, the default, or :watching through the optional listen gem), and poll_interval (default 1 second, raised to the 1 second minimum with a warning). Invalid options raise ArgumentError when the client is created, the same way other invalid component configuration is reported. Unlike the Go reference, an unrecognized duplicate_keys_handling value and an unknown option key are rejected rather than defaulted, because the specification treats invalid configuration as a construction error and an emergency mechanism should fail loudly.

Behavior comes from the shared file data code added in #449: 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 and keeps the last good overrides, with a logged failure and a retry; a rewrite with identical content is not reapplied; the initial load completes before the client constructor returns. A flagValues entry expands into a flag that is on and serves the value by fallthrough, so the evaluation reports the FALLTHROUGH reason kind. Every applied change is logged at Info with the overrides in effect and what each file supplied, and the reloader's log lines for this source carry a FileOverrideSource prefix.

Verification: specs for the builder (defaults, absolute paths, every invalid option, listen requirement, poll interval clamping), the initial load (merge, fallthrough-form expansion, YAML, missing file, all files missing, malformed file, duplicate keys under both handlings), the Info log format, polling change detection (change, appearance, deletion, malformed edit with recovery, identical rewrite, stop, stop before start), watching change detection (change, appearance, deletion), and a client-level check of serving and reloading overrides through LDClient. Full suite and RuboCop are clean. Each new spec was checked against a deliberate defect in the code it covers.

The existing FDv1 and FDv2 file data sources keep their current behavior. This series does not change them; the override feature is additive.

SDK-3249


Note

Overview
Adds LaunchDarkly::Integrations::FileData.override_source, an experimental file-based override source wired through DataSystem::ConfigBuilder#overrides. Operators can point at JSON/YAML files (same format as the file data source) so per-key flag and segment definitions override LaunchDarkly at evaluation time while the client stays connected.

The implementation (FileOverrideSource) loads and merges files via the shared FileData::Reloader, with missing paths ignored, unchanged content skipped, polling or listen-based watching, and strict option validation at LDClient construction. Each successful apply pushes a full snapshot to the override sink and logs what is in effect per file.

FileData::Reloader gains a configurable log_prefix (used by the override source) and inlines unexpected-error logging instead of Util.log_exception. Existing FDv1/FDv2 file data sources are unchanged.

Specs cover the builder, load/reload behavior, logging, change detection, and client-level override evaluation.

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

@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-events branch from 89f544e to be39b66 Compare September 25, 2026 22:51
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-file-source branch from 52a065f to 605d0ab Compare September 25, 2026 22:51
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-events branch from be39b66 to 6ff51f4 Compare September 28, 2026 20:36
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-file-source branch from 605d0ab to 5bda436 Compare September 28, 2026 20:36
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-events branch from 6ff51f4 to e0dd518 Compare October 1, 2026 23:43
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-file-source branch from 5bda436 to 4287523 Compare October 1, 2026 23:43
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-events branch from e0dd518 to 356fee9 Compare October 3, 2026 00:46
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-file-source branch from 4287523 to 703e368 Compare October 3, 2026 00:46
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@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.

✅ 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 703e368. Configure here.

@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-events branch from 356fee9 to de05ef4 Compare October 3, 2026 01:54
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-file-source branch from 703e368 to 18d4335 Compare October 3, 2026 01:54
Adds `LaunchDarkly::Integrations::FileData.override_source`, the file-based
override source that the OVERRIDE specification defines, for use with
`LaunchDarkly::DataSystem::ConfigBuilder#overrides`.

The source reads one or more JSON or YAML files in the file data source
document format (`flags`, `flagValues`, `segments`) and supplies complete
snapshots to the SDK's override store. Options: `paths` (required, in
precedence order), `duplicate_keys_handling` (`:fail`, the default, or
`:ignore`, which keeps the first file's entry), `change_detection`
(`:polling`, the default, or `:watching` through the optional listen gem),
and `poll_interval` (default 1 second, raised to the 1 second minimum with
a warning). Invalid options, including an unknown option key, raise
`ArgumentError` when the client is created.

Behavior comes from the shared file data code: 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 and keeps the last good overrides,
with a logged failure and a retry. A rewrite with identical content is
not reapplied. The initial load completes before the client constructor
returns. A `flagValues` entry expands into a flag that is off and serves
the value, so the evaluation reports the OFF reason kind. Every applied
change is logged at Info with the overrides in effect and what each file
supplied. The reloader's log lines for this source carry a
FileOverrideSource prefix.

Flag overrides are currently experimental and subject to change.
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-events branch from de05ef4 to aae4984 Compare October 8, 2026 16:54
@kinyoklion
kinyoklion force-pushed the rlamb/overrides-ruby-file-source branch from 18d4335 to d4f7481 Compare October 8, 2026 16:55

This branch has not been deployed

No deployments
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.

1 participant