fix: Check disabled state before AI Config mode mismatch#1758
Draft
jsonbailey wants to merge 2 commits into
Draft
fix: Check disabled state before AI Config mode mismatch#1758jsonbailey wants to merge 2 commits into
jsonbailey wants to merge 2 commits into
Conversation
Contributor
|
@launchdarkly/js-client-sdk size report |
Contributor
|
@launchdarkly/js-sdk-common size report |
Contributor
|
@launchdarkly/js-client-sdk-common size report |
Contributor
|
@launchdarkly/browser size report |
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.
This PR fixes two related issues in
LDAIClientImpl._evaluate()in theserver-aipackage, both around how a served AI Config variation's mode is reconciled with the mode the caller requested.Fix 1 — Check disabled state before the mode comparison
Bug: A disabled AI Config variation is served by LaunchDarkly as
{"_ldMeta": {"enabled": false}}with nomodefield. The mode-mismatch check ran before the enabled check, so the absent mode defaulted to'completion'. CallingagentConfig()(orjudgeConfig()) on a disabled config then made'completion' !== 'agent'true and emitted a spurious warning:The config was simply disabled, not a genuine mode mismatch.
Fix: Short-circuit disabled variations before the mode comparison. When
value._ldMeta?.enabled === false,_evaluate()returnsLDAIConfigUtils.createDisabledConfig(key, mode, ...)of the requested mode — no mode comparison, no warning. (=== falsematches the existing disabled-check convention inagentGraph().)Fix 2 — Return the caller's default on a genuine mode mismatch
Bug (pre-existing): When a config is enabled but its mode genuinely differs from what the caller requested (e.g. an enabled completion config requested via
agentConfig()), js-core logged "...Returning disabled config." and returned an empty disabled config. Per the AI Config spec (the "mode mismatch returns the caller's supplied default" rule, merged tosdk-specsmain via PR #229 / AIC-2207), the SDK must instead return the caller's supplied default of the requested mode. .NET already does this; js-core was off-spec.Fix: In the genuine-mismatch branch (which now only runs for enabled configs, after Fix 1's disabled short-circuit), build the returned config from the caller's supplied default (converted to the requested mode via the already-computed
ldFlagValue) instead of an empty disabled config. The warning text now reads "Returning caller's default." to match the new behavior and .NET's wording. Matching-mode and disabled paths are unchanged.Tests
{"_ldMeta": {"enabled": false}}) assert no mode-mismatch warning and a disabled config of the requested type — unchanged and still passing.Companion changes
sdk-specson branchjb/disabled-config-mode-check.dotnet-coreon branchjb/disabled-config-mode-check.No changelog or version edits (handled at release time).
BEGIN_COMMIT_OVERRIDE
fix: Check disabled state before AI Config mode mismatch
fix: Return caller's default on AI Config mode mismatch
END_COMMIT_OVERRIDE