fix: Reject "multi" as the kind of an individual context#272
Open
kinyoklion wants to merge 1 commit into
Open
Conversation
The "multi" kind string is reserved as the discriminator for the
multi-context wrapper. An individual context must not use it. The
internal _validKind helper was only rejecting "kind"; building with
.kind("multi", ...) was producing a valid LDContext, and a multi-context
that included "multi" as one of its sub-kinds was also valid.
Extends the existing invalid-kinds group with the single-kind case and
adds a separate test for the multi-context case (which exercises the
"any sub-kind invalid → whole context invalid" path).
tanderson-ld
approved these changes
May 21, 2026
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.
Refs SDK-2383.
Summary
The string
"multi"is reserved as the LaunchDarkly multi-context discriminator. An individual context must not use"multi"as its kind. The internal_validKindhelper inpackages/common/lib/src/ld_context.dartwas only rejecting"kind"; building with.kind("multi", ...)was producing a validLDContext, and a multi-context that included"multi"as one of its sub-kinds was also valid.This propagates the kind validation Flutter SDK already implements for
"kind"to also cover"multi". Both single-kind and multi-context build paths run every sub-kind through_validKind, so a single change covers both.Test plan
flutter test test/ld_context_test.dart— 36 tests pass (new + existing)flutter test(full common package) — 437 tests passdart analyze --fatal-infos lib test— no issuesdart format— no changesLDContextBuilder().kind('multi', 'alice').build().validis nowfalse; previouslytrue"multi"sub-kind builds as invalidNote
Low Risk
Low risk: a small validation tightening that only changes behavior for previously-accepted invalid input (kind == "multi"). Main risk is backward incompatibility for callers incorrectly using "multi" as a kind, now producing invalid contexts.
Overview
Reserves
"multi"by updating kind validation so an individual context cannot usekind == "multi", causing such contexts (and multi-contexts that include a"multi"sub-kind) to build as invalid.Updates tests to treat
"multi"as an invalid kind and adds coverage ensuring invalid contexts return emptycanonicalKeyandkeys.Reviewed by Cursor Bugbot for commit a2abb8f. Bugbot is set up for automated code reviews on this repo. Configure here.