Repository navigation
fix: Prefer a targeting key of "0" over the key attribute - #44
Merged
Merged
Conversation
getTargetingKey() used `$targetingKey ?: $key` to fall back to the key attribute. "0" is falsy in PHP, so a targeting key of "0" was replaced by the key attribute, even though the targeting key should take precedence. Fall back to the key attribute only when the targeting key is null or an empty string, matching the check earlier in the same method.
…ribute Add single-context and multi-kind context cases, since both go through getTargetingKey().
zigzagdev
marked this pull request as draft
November 22, 2026 11:39
zigzagdev
marked this pull request as ready for review
November 22, 2026 14:51
keelerm84
approved these changes
Nov 23, 2026
Member
|
Thank you @zigzagdev for this contribution! |
keelerm84
pushed a commit
that referenced
this pull request
Nov 24, 2026
🤖 I have created a release *beep* *boop* --- ## [2.1.2](2.1.1...2.1.2) (2026-11-23) ### Bug Fixes * Prefer a targeting key of "0" over the key attribute ([#44](#44)) ([68554ef](68554ef)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[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.
Requirements
Related issues
N/A
Describe the solution you've provided
The targeting key now takes precedence over the
keyattribute. It falls back tokeyonly when the targeting key isnullor"".Reason
getTargetingKey()falls back tokeywith$targetingKey ?: $key. Since"0"is falsy in PHP, a targeting key of"0"is replaced by thekeyattribute.For example:
In this case, the context key is
abcinstead of0.Describe alternatives you've considered
None
Additional context
Added tests for single-context and multi-kind context cases. Both fail without the fix.
Note
Overview
Fixes targeting key resolution in
EvaluationContextConverter::getTargetingKeyso a providedtargetingKeyof"0"is no longer treated as missing. The fallback to the attributekeynow runs only whentargetingKeyisnullor"", instead of relying on PHP’s falsy?:behavior.Adds tests for single- and multi-kind contexts confirming
"0"wins over a conflicting attributekey.Reviewed by Cursor Bugbot for commit d7bb028. Bugbot is set up for automated code reviews on this repo. Configure here.