Skip to content

fix(AIC-3572): treat a variation without _ldMeta.enabled as disabled - #184

Merged
jeffdupont merged 1 commit into
mainfrom
jdupont/aic-3572-missing-enabled
Oct 21, 2026
Merged

jeffdupont merged 1 commit into
mainfrom
jdupont/aic-3572-missing-enabled

Conversation

@jeffdupont

@jeffdupont jeffdupont commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes AIC-3572.

Why

When a variation comes back with no _ldMeta, or with _ldMeta but no enabled field, extract_variation treated it as enabled and ran the model. Only an explicit enabled: false was refused. The JS SDK (lifecycle.ts, if (!variation?._ldMeta?.enabled) throw) and the Go SDK (aiserver/lifecycle.go, if !meta.Enabled) both refuse these variations, and Python's own inspect_config already reports them as enabled: false, so one SDK said "disabled" while the other ran the call.

Behaviour change (changelog): a config served without _ldMeta.enabled (for example a plain JSON flag used as an AI config) now raises Variation '<key>' is disabled. instead of running.

Fix

  • packages/client/src/launchdarkly_ai_server/lifecycle.py: extract_variation raises the existing "is disabled" error unless _ldMeta is a dict with a truthy enabled. A non-dict or null _ldMeta is guarded. meta["enabled"] is now always True past that check.
  • packages/client/tests/test_lifecycle.py: new TestExtractVariationMissingEnabled, parametrized over no _ldMeta and _ldMeta: {}. Each case asserts that extract_variation raises and inspect_config returns enabled: False.

Testing

  • make test: 2546 passed, 14 skipped
  • make typecheck: no issues in 75 source files
  • make lint: all checks passed. make format-check: 161 files already formatted.
  • Without the fix, both new cases fail with DID NOT RAISE RuntimeError.
  • Every existing fixture sets _ldMeta.enabled explicitly, and the full suite passes unchanged.

Related: https://github.com/launchdarkly/ai-sdks-monorepo/pull/69

🤖 Generated with Claude Code


Note

Overview
Aligns Python extract_variation with spec §3.10 and the JS/Go SDKs: a variation is only runnable when _ldMeta is a dict with a truthy enabled. Missing _ldMeta, an empty _ldMeta, or no enabled field now raises Variation '<key>' is disabled. instead of proceeding to parse and invoke the model (previously only enabled: false was rejected).

After that gate, returned meta["enabled"] is always True rather than defaulting from metadata. inspect_config already reported these cases as disabled; invoke paths now match.

Adds parametrized tests (no_ldMeta, empty_ldMeta) asserting extract_variation raises and inspect_config returns enabled: false.

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

extract_variation only refused `_ldMeta.enabled is False` and defaulted a
missing flag to enabled. JS and Go refuse anything but an explicit
enabled: true, and inspect_config already reported these as disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeffdupont
jeffdupont requested a review from a team October 21, 2026 15:20
@jeffdupont
jeffdupont merged commit 7a0d260 into main Oct 21, 2026
8 checks passed
@jeffdupont
jeffdupont deleted the jdupont/aic-3572-missing-enabled branch October 21, 2026 20:12
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
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.

3 participants