Skip to content

Commit fac9ec8

Browse files
committed
docs: Note that a flagValues override is not available to client-side SDKs
A flagValues entry becomes a flag without client-side availability, so an all-flags state for client-side SDKs leaves it out even when the flag it overrides is client-side. A full definition with clientSide is the way to override such a flag. A test pins both.
1 parent f2b71a1 commit fac9ec8

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎ldclient/integrations/overrides.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ class FileOverrideSourceBuilder(OverrideSourceBuilder):
5454
as the files change. The files use the same document format as the file data source:
5555
each file is a JSON or YAML document with optional ``flags``, ``flagValues``, and
5656
``segments`` members. ``flagValues`` entries are expanded into full flag definitions that
57-
return the given value for every context. YAML requires the ``pyyaml`` package.
57+
return the given value for every context. A ``flagValues`` entry is not available to
58+
client-side SDKs, so :meth:`ldclient.client.LDClient.all_flags_state` with
59+
``client_side_only=True`` leaves it out, even when the flag it overrides is available to them.
60+
To override such a flag, define it in ``flags`` with ``"clientSide": true``. YAML requires the
61+
``pyyaml`` package.
5862
5963
When multiple files are configured, their entries are combined in the configured order.
6064
The order determines which file wins under the duplicate keys handling. A reload replaces

‎ldclient/testing/integrations/test_file_override_source.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,22 @@ def changed() -> bool:
537537
# The override is removed. The not-initialized short-circuit returns.
538538
write_file(path, '{}')
539539
eventually(lambda: client.variation_detail('overridden-flag', user, False).reason.get('errorKind') == 'CLIENT_NOT_READY', "the removed override was not picked up")
540+
541+
542+
def test_client_side_all_flags_state_includes_a_full_definition_with_client_side_but_not_a_value_entry(tmp_path):
543+
# A flagValues entry is not available to client-side SDKs. A full definition that sets
544+
# clientSide is, so that is how an operator overrides a flag that client-side SDKs use.
545+
path = os.path.join(str(tmp_path), 'overrides.json')
546+
write_file(path, '{"flagValues": {"value-flag": true}, '
547+
'"flags": {"full-flag": {"key": "full-flag", "version": 1, "on": true, "variations": [true], '
548+
'"fallthrough": {"variation": 0}, "clientSide": true}}}')
549+
source = FileOverrideSourceBuilder([path])
550+
datasystem = custom().synchronizers(HangingSynchronizer().builder).overrides(source).build()
551+
config = Config(sdk_key='SDK_KEY', datasystem_config=datasystem, event_processor_class=MockEventProcessor)
552+
553+
with LDClient(config, start_wait=0) as client:
554+
user = Context.create('user-key')
555+
assert set(client.all_flags_state(user).to_values_map().keys()) == {'value-flag', 'full-flag'}
556+
state = client.all_flags_state(user, client_side_only=True)
557+
assert state.valid
558+
assert state.to_values_map() == {'full-flag': True}

0 commit comments

Comments
 (0)