fix!: Do not add the targeting key as a custom attribute - #28
Merged
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
@cursor review |
kinyoklion
marked this pull request as ready for review
August 31, 2026 21:25
3 tasks
keelerm84
approved these changes
Sep 1, 2026
kinyoklion
added a commit
that referenced
this pull request
Sep 1, 2026
Adds a feature matrix to the README, mirroring the OpenFeature PHP SDK's own matrix, so a reader can see at a glance what this provider does and does not do. - Most unsupported rows are limitations of the OpenFeature PHP SDK, not of this provider — eventing, shutdown, named clients, tracking, transaction context and flag metadata have no place in that SDK's provider interface — and each row says so, so they are not read as provider gaps. - Format matches the matrices added to the Java, Python, .NET and JavaScript providers this week, so the providers can be compared side by side. <details> <summary>Implementation details</summary> Rows and statuses were checked against the OpenFeature PHP SDK 2.3.0 and the LaunchDarkly PHP SDK 6.8.3 rather than copied from another provider: `OpenFeature\interfaces\provider\Provider` declares only the five `resolve*Value` methods plus hooks, logger and metadata accessors, `ProviderAware` holds a single provider for the whole API, and neither `EvaluationDetails` nor `ResolutionDetails` carries flag metadata. The three separate fixes opened alongside this (#27, #28, #29) are provider-side bugs within rows the matrix marks as supported, so they do not change any status here. **Requirements** - [x] I have added test coverage for new or changed functionality - [x] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [x] I have validated my changes against all supported platform versions **Related issues** None. **Describe the solution you've provided** A `## Feature matrix` section after the supported-versions section, with the same `Status | Feature | Notes` shape as the other LaunchDarkly OpenFeature providers. **Describe alternatives you've considered** Listing only the rows the OpenFeature PHP SDK's own matrix has: it would drop initialization, tracking, transaction context and flag metadata, which are exactly the rows readers coming from another LaunchDarkly provider will look for. **Additional context** Testing: documentation only; `make check` still passes. </details> Link to Devin session: https://app.devin.ai/sessions/38a6eaf69fcf41109e136a1d0fe5e899 Open in Devin Desktop: https://app.devin.ai/desktop/session/38a6eaf69fcf41109e136a1d0fe5e899?variant=devin Requested by: @kinyoklion <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Adds a **Feature matrix** section to the README (after supported PHP versions), aligned with the [OpenFeature PHP SDK feature list](https://github.com/open-feature/php-sdk#-features) and the same table shape used on other LaunchDarkly OpenFeature providers. > > The table lists each capability with ✅/❌ status and notes: supported areas (flag types, targeting, hooks, logging, MultiProvider, extending via `LDClient`) and unsupported rows that call out whether the gap is the OpenFeature PHP SDK (e.g. named clients, eventing, shutdown, tracking, transaction context, flag metadata) versus provider behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit da8803a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Stops
targetingKeyfrom being copied into the LaunchDarkly context as a custom attribute.$key === "targetingKey") instead of the attribute name ($k === "targetingKey"), so the attribute was never skipped.targetingKeyattribute per sub-context, where it was visible to targeting rules and on the context in the LaunchDarkly UI.Before, for
{"kind": "multi", "organization": {"targetingKey": "org-key", "name": "the-org"}}:{"kind":"multi","organization":{"key":"org-key","name":"the-org","targetingKey":"org-key"}}Implementation details
Found during the weekly OpenFeature provider audit.
OFPrequirement 2.3 namestargetingKeyas the source of the context key, and 2.4 only requires attributes not named in that section to become custom attributes, so this was a spec violation as well as noise.Only multi-contexts were affected in practice: for a single context the OpenFeature SDK keeps the targeting key outside the attributes, while a multi-context has to carry a
targetingKeyinside each per-kind attribute map. The fix is in the shared single-context builder, which handles both.Requirements
Related issues
None.
Describe the solution you've provided
The attribute name is compared to
"targetingKey", as was clearly intended by the surrounding code and its comment.Describe alternatives you've considered
Filtering the attribute out in the multi-context builder only: that leaves the same latent bug in the single-context path if the SDK ever surfaces a
targetingKeyattribute there.Additional context
Testing:
make check(composer cs-check,composer phpstan,composer phpunit). The new test asserts both that the sub-context key is still taken fromtargetingKeyand that no such custom attribute remains.Link to Devin session: https://app.devin.ai/sessions/38a6eaf69fcf41109e136a1d0fe5e899
Open in Devin Desktop: https://app.devin.ai/desktop/session/38a6eaf69fcf41109e136a1d0fe5e899?variant=devin
Requested by: @kinyoklion
Note
Overview
Fixes a one-character logic bug in
buildSingleContextwhere the skip check used$key === "targetingKey"(the resolved context key) instead of$k === "targetingKey"(the attribute name).keywas already skipped correctly;targetingKeywas not, so multi-context evaluations could emit a duplicatetargetingKeycustom attribute on each sub-context while still using it for the LD context key.Adds
testMultiContextTargetingKeyIsNotAddedAsAnAttributeto assert the sub-context key comes fromtargetingKeyand thattargetingKeydoes not appear in serialized context JSON.Reviewed by Cursor Bugbot for commit 9262dde. Bugbot is set up for automated code reviews on this repo. Configure here.