fix(flags): resolve payloads during local evaluation - #243
Merged
marandaneto merged 2 commits intoSep 14, 2026
Merged
Conversation
Member
|
thanks @okremer84 |
Local flag definitions already carry filters.payloads, but both evaluateFlags() and the single-flag path recorded payload: null for a locally computed value, so getFlagPayload() only ever worked after a remote /flags request. Read the payload from the definition, keyed by the variant or "true" for a boolean flag, mirroring the remote path's handling of pre-decoded values.
marandaneto
approved these changes
Sep 14, 2026
marandaneto
force-pushed
the
fix/local-evaluation-payloads
branch
from
September 14, 2026 06:08
2e7f928 to
cf7edfb
Compare
Member
|
fixed |
marandaneto
enabled auto-merge (squash)
September 14, 2026 06:09
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.
Problem
Local flag definitions from
/flags/definitionsalready includefilters.payloads, but locally evaluated flags never expose them:evaluateFlags()builds eachEvaluatedFlagRecordwithpayload: nullon the local path, and the single-flag path (getFeatureFlagResult()/getFeatureFlagPayload()) leaves$payloadnull whenever the flag was computed locally.getFlagPayload()therefore only works after a remote/flagsrequest, which defeats local evaluation for any flag whose payload is the point (config-as-flag, per-variant experiment parameters).Fix
Read the payload from the definition's
filters.payloadsmap, keyed by the variant for a multivariate flag or by"true"for a boolean flag that is on, and decode it the same way the remote path does (JSON string, or accept a pre-decoded value). A flag that is off yields no payload. One private helper, used by both local paths. No public API change.Tests
testLocalEvaluationResolvesPayloadscovers a boolean flag with a JSON payload, a multivariate flag whose winning variant carries a pre-decoded payload, an inactive flag with a payload, and asserts no/flagsrequest is made.Full suite: the only failures are the four
ExceptionCaptureTestcases that also fail onmasterin my environment (error-handler/exit behaviour under PHPUnit), unrelated to this change.