feat: expose OpenFeature flag metadata - #180
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughMetadata support is added to provider and evaluation resolution details, including nullable storage, fluent builders, interface accessors, factory propagation, and tests for populated, empty, and null metadata. ChangesMetadata propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Provider
participant ResolutionDetailsBuilder
participant ResolutionDetails
participant EvaluationDetailsFactory
participant EvaluationDetailsBuilder
participant EvaluationDetails
Provider->>ResolutionDetailsBuilder: withMetadata(metadata)
ResolutionDetailsBuilder->>ResolutionDetails: setMetadata(metadata)
Provider->>EvaluationDetailsFactory: fromResolution(details)
EvaluationDetailsFactory->>ResolutionDetails: getMetadata()
EvaluationDetailsFactory->>EvaluationDetailsBuilder: withMetadata(metadata)
EvaluationDetailsBuilder->>EvaluationDetails: setMetadata(metadata)
EvaluationDetails-->>Provider: getMetadata()
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/interfaces/flags/EvaluationDetails.php`:
- Around line 72-78: Update EvaluationDetailsInterface::getMetadata() to return
a non-null array<string,bool|string|int>. In EvaluationDetails, initialize the
metadata field to [] and normalize null values to [] in setMetadata(null), while
preserving provided metadata values.
In `@src/interfaces/provider/ResolutionDetails.php`:
- Around line 54-63: Preserve backward compatibility by removing or making
non-required the newly added metadata methods in both
src/interfaces/provider/ResolutionDetails.php (lines 54-63) and
src/interfaces/flags/EvaluationDetails.php (lines 68-78), retaining the previous
public interface signatures; alternatively, explicitly treat these interface
changes as a major-version change.
In `@tests/unit/ProviderResolutionResultTest.php`:
- Around line 88-94: Update both metadata tests using ProviderResolutionResult
to pass the existing $details object as the third constructor argument instead
of null, then assert that getDetails() returns the identical object with
assertSame($details, $result->getDetails()).
- Around line 103-114: Rename testResultWithEmptyMetadata() to
testResultWithNullMetadata() while preserving its null-metadata assertions, then
add a separate empty-metadata test using detailsWithMetadata(true, []) that
asserts getMetadata() returns exactly [] via assertSame.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cbe1e656-6dcb-4e17-b60d-46a219b4e241
📒 Files selected for processing (8)
src/implementation/flags/EvaluationDetails.phpsrc/implementation/flags/EvaluationDetailsBuilder.phpsrc/implementation/flags/EvaluationDetailsFactory.phpsrc/implementation/provider/ResolutionDetails.phpsrc/implementation/provider/ResolutionDetailsBuilder.phpsrc/interfaces/flags/EvaluationDetails.phpsrc/interfaces/provider/ResolutionDetails.phptests/unit/ProviderResolutionResultTest.php
fcff395 to
f4f51bc
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unit/ProviderResolutionResultTest.php (1)
81-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd an evaluation-side propagation test.
These tests only inspect
ResolutionDetails; a regression inEvaluationDetailsFactory::fromResolution()could drop metadata and still pass. Add a factory test for populated metadata and fornullresolution metadata becoming[]in evaluation details, as required by OpenFeature 1.4.14. (openfeature.dev)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/ProviderResolutionResultTest.php` around lines 81 - 127, Add factory-level tests covering EvaluationDetailsFactory::fromResolution(): verify populated resolution metadata is preserved in the resulting evaluation details, and verify null resolution metadata is converted to an empty array. Keep the existing ResolutionDetails assertions unchanged and use the established test fixtures and evaluation-details accessors.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/implementation/flags/EvaluationDetails.php`:
- Around line 22-23: Widen the metadata PHPDoc contracts from bool|string|int to
bool|string|int|float across EvaluationDetails::$metadata and its setter/getter
annotations in EvaluationDetails.php (22-23 and 91-120), and the builder
parameter annotation in ResolutionDetailsBuilder.php (51-54); preserve the
existing runtime behavior.
---
Nitpick comments:
In `@tests/unit/ProviderResolutionResultTest.php`:
- Around line 81-127: Add factory-level tests covering
EvaluationDetailsFactory::fromResolution(): verify populated resolution metadata
is preserved in the resulting evaluation details, and verify null resolution
metadata is converted to an empty array. Keep the existing ResolutionDetails
assertions unchanged and use the established test fixtures and
evaluation-details accessors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 96afde42-0a87-41a5-ab92-123145f16839
📒 Files selected for processing (8)
src/implementation/flags/EvaluationDetails.phpsrc/implementation/flags/EvaluationDetailsBuilder.phpsrc/implementation/flags/EvaluationDetailsFactory.phpsrc/implementation/provider/ResolutionDetails.phpsrc/implementation/provider/ResolutionDetailsBuilder.phpsrc/interfaces/flags/EvaluationDetails.phpsrc/interfaces/provider/ResolutionDetails.phptests/unit/ProviderResolutionResultTest.php
🚧 Files skipped from review as they are similar to previous changes (5)
- src/interfaces/flags/EvaluationDetails.php
- src/implementation/flags/EvaluationDetailsFactory.php
- src/implementation/flags/EvaluationDetailsBuilder.php
- src/implementation/provider/ResolutionDetails.php
- src/interfaces/provider/ResolutionDetails.php
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@tcarrio would you have any chance to review the PR? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #180 +/- ##
============================================
+ Coverage 95.19% 96.93% +1.74%
- Complexity 227 350 +123
============================================
Files 40 50 +10
Lines 583 882 +299
============================================
+ Hits 555 855 +300
+ Misses 28 27 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
It looks like your unit test coverage is too low. This is likely due to lack of tests explicitly covering the evaluation details metadata |
Signed-off-by: vi-verrone vi.verrone@gmail.com Resolve issue open-feature#180
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unit/ResolutionDetailsMetadataTest.php (1)
35-42: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover explicit nullable metadata assignment across both builder layers.
The helpers only accept non-null arrays, while the builder contracts accept
?array; current no-metadata tests cover default state but not explicitwithMetadata(null)assignment.
tests/unit/ResolutionDetailsMetadataTest.php#L35-L42: allow nullable metadata or add a dedicatedwithMetadata(null)test.tests/unit/EvaluationDetailsMetadataTest.php#L38-L45: add explicit null coverage for EvaluationDetailsBuilder.tests/unit/EvaluationDetailsMetadataTest.php#L55-L62: add explicit null coverage for ResolutionDetailsBuilder and factory propagation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/ResolutionDetailsMetadataTest.php` around lines 35 - 42, Update tests/unit/ResolutionDetailsMetadataTest.php:35-42 by allowing the detailsWithMetadata helper to accept nullable metadata and add explicit withMetadata(null) coverage. In tests/unit/EvaluationDetailsMetadataTest.php:38-45, add null metadata coverage for EvaluationDetailsBuilder; in tests/unit/EvaluationDetailsMetadataTest.php:55-62, add null coverage for ResolutionDetailsBuilder and verify factory propagation. Ensure all cases assert the expected null metadata state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/EvaluationDetailsMetadataTest.php`:
- Around line 109-133: The metadata tests should assert exact propagated values
rather than only type, emptiness, identity, or key presence. In
testEvaluationDetailsFromResolutionDetailsWithoutMetadata, assert that
details->getMetadata() equals an empty array; in
testEvaluationDetailsFromResolutionDetailsWithMetadata, assert it equals ['key'
=> 'value'] while preserving the existing source-metadata checks.
---
Nitpick comments:
In `@tests/unit/ResolutionDetailsMetadataTest.php`:
- Around line 35-42: Update tests/unit/ResolutionDetailsMetadataTest.php:35-42
by allowing the detailsWithMetadata helper to accept nullable metadata and add
explicit withMetadata(null) coverage. In
tests/unit/EvaluationDetailsMetadataTest.php:38-45, add null metadata coverage
for EvaluationDetailsBuilder; in
tests/unit/EvaluationDetailsMetadataTest.php:55-62, add null coverage for
ResolutionDetailsBuilder and verify factory propagation. Ensure all cases assert
the expected null metadata state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: dd6975f2-ecbf-40da-8887-544434c130bb
📒 Files selected for processing (2)
tests/unit/EvaluationDetailsMetadataTest.phptests/unit/ResolutionDetailsMetadataTest.php
…onDetails and ResolutionDetails getMetadata() and setMetadata() have been added to EvaluationDetails and ResolutionDetails to respect OpenFeature requirements 1.4.14 and 2.2.9 Signed-off-by: vi-verrone <vi.verrone@gmail.com>
Signed-off-by: vi-verrone <vi.verrone@gmail.com>
Signed-off Signed-off-by: vi-verrone <vi.verrone@gmail.com>
Signed-off-by: vi-verrone vi.verrone@gmail.com Resolve issue open-feature#180 Signed-off-by: vi-verrone <vi.verrone@gmail.com>
🤖 I have created a release *beep* *boop* --- ## [2.3.0](open-feature/php-sdk@2.2.0...2.3.0) (2026-06-10) ### ✨ New Features * support isolated API instances ([open-feature#171](open-feature#171)) ([48301ee](open-feature@48301ee)) --- 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> Signed-off-by: vi-verrone <vi.verrone@gmail.com>
740d086 to
2c4955d
Compare
|
@tcarrio would you have any chance to review again the PR and make Codecov start the analysis? Thanks for your time. |
…e-php-sdk into feat/expose-flag-metadata-with-ResolutionDetailBuilder Signed-off-by: vi-verrone <vi.verrone@gmail.com>
Signed-off-by: vi-verrone <vi.verrone@gmail.com>
|
@tcarrio let me know if the PR can be validated and eventually merged, or if there is something more to be added/changed/handled. |
Expose flag metadata through getMetadata() method on EvaluationDetails and ResolutionDetails
getMetadata() and setMetadata() have been added to EvaluationDetails and ResolutionDetails to respect OpenFeature requirements 1.4.14 and 2.2.9
This PR
Related Issues
#181
Notes
Follow-up Tasks
php-sdk-contrib: [FEATURE] providers -> GoFeatureFlag: provide flag metadata with getMetadata() or getFlagMetadata() in evaluation response php-sdk-contrib#175How to test