Skip to content

feat: expose OpenFeature flag metadata - #180

Open
vi-verrone wants to merge 7 commits into
open-feature:mainfrom
vi-verrone:feat/expose-flag-metadata-with-ResolutionDetailBuilder
Open

feat: expose OpenFeature flag metadata #180
vi-verrone wants to merge 7 commits into
open-feature:mainfrom
vi-verrone:feat/expose-flag-metadata-with-ResolutionDetailBuilder

Conversation

@vi-verrone

@vi-verrone vi-verrone commented Jul 22, 2026

Copy link
Copy Markdown

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

  • adds getMetadata() and setMetadata() to EvaluationDetails and ResolutionDetails classes
  • adds withMetadata() to EvaluationDetailsBuilder and ResolutionDetailsBuilder classes

Related Issues

#181

Notes

Follow-up Tasks

How to test

@vi-verrone
vi-verrone requested a review from tcarrio as a code owner July 22, 2026 18:11
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c815d724-2b00-4b86-81dc-892993ebf137

📥 Commits

Reviewing files that changed from the base of the PR and between 0ccfd28 and 43dac9b.

📒 Files selected for processing (10)
  • src/implementation/flags/EvaluationDetails.php
  • src/implementation/flags/EvaluationDetailsBuilder.php
  • src/implementation/flags/EvaluationDetailsFactory.php
  • src/implementation/provider/ResolutionDetails.php
  • src/implementation/provider/ResolutionDetailsBuilder.php
  • src/interfaces/flags/EvaluationDetails.php
  • src/interfaces/provider/ResolutionDetails.php
  • tests/unit/EvaluationDetailsMetadataTest.php
  • tests/unit/ProviderResolutionResultTest.php
  • tests/unit/ResolutionDetailsMetadataTest.php

📝 Walkthrough

Walkthrough

Metadata 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.

Changes

Metadata propagation

Layer / File(s) Summary
Provider metadata contract and storage
src/interfaces/provider/ResolutionDetails.php, src/implementation/provider/ResolutionDetails.php, src/implementation/provider/ResolutionDetailsBuilder.php, tests/unit/ResolutionDetailsMetadataTest.php
Resolution details now accept, store, copy, and return nullable metadata through the builder and accessor, with coverage for null, empty, populated, and immutable metadata.
Evaluation metadata propagation
src/interfaces/flags/EvaluationDetails.php, src/implementation/flags/EvaluationDetails.php, src/implementation/flags/EvaluationDetailsBuilder.php, src/implementation/flags/EvaluationDetailsFactory.php, tests/unit/EvaluationDetailsMetadataTest.php
Evaluation details expose metadata, and the factory forwards metadata from resolution details into the evaluation builder with coverage for empty, populated, and immutable results.
Resolution result metadata validation
tests/unit/ProviderResolutionResultTest.php
Provider resolution result tests cover populated, empty, and null metadata alongside successful result status assertions.

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()
Loading

Possibly related issues

  • open-feature/php-sdk#181 — Directly addresses flag metadata support across resolution details, evaluation details, builders, and factory propagation.

Suggested reviewers: tcarrio

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: exposing OpenFeature flag metadata.
Description check ✅ Passed The description accurately describes the metadata API additions and related builder updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 48301ee and 58bd0ea.

📒 Files selected for processing (8)
  • src/implementation/flags/EvaluationDetails.php
  • src/implementation/flags/EvaluationDetailsBuilder.php
  • src/implementation/flags/EvaluationDetailsFactory.php
  • src/implementation/provider/ResolutionDetails.php
  • src/implementation/provider/ResolutionDetailsBuilder.php
  • src/interfaces/flags/EvaluationDetails.php
  • src/interfaces/provider/ResolutionDetails.php
  • tests/unit/ProviderResolutionResultTest.php

Comment thread src/interfaces/flags/EvaluationDetails.php Outdated
Comment thread src/interfaces/provider/ResolutionDetails.php
Comment thread tests/unit/ProviderResolutionResultTest.php Outdated
Comment thread tests/unit/ProviderResolutionResultTest.php
@vi-verrone
vi-verrone force-pushed the feat/expose-flag-metadata-with-ResolutionDetailBuilder branch from fcff395 to f4f51bc Compare July 22, 2026 19:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unit/ProviderResolutionResultTest.php (1)

81-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add an evaluation-side propagation test.

These tests only inspect ResolutionDetails; a regression in EvaluationDetailsFactory::fromResolution() could drop metadata and still pass. Add a factory test for populated metadata and for null resolution 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

📥 Commits

Reviewing files that changed from the base of the PR and between 58bd0ea and f4f51bc.

📒 Files selected for processing (8)
  • src/implementation/flags/EvaluationDetails.php
  • src/implementation/flags/EvaluationDetailsBuilder.php
  • src/implementation/flags/EvaluationDetailsFactory.php
  • src/implementation/provider/ResolutionDetails.php
  • src/implementation/provider/ResolutionDetailsBuilder.php
  • src/interfaces/flags/EvaluationDetails.php
  • src/interfaces/provider/ResolutionDetails.php
  • tests/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

Comment thread src/implementation/flags/EvaluationDetails.php Outdated
@vi-verrone

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vi-verrone

Copy link
Copy Markdown
Author

@tcarrio would you have any chance to review the PR?

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.93%. Comparing base (2123274) to head (2c4955d).
⚠️ Report is 35 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tcarrio

tcarrio commented Jul 26, 2026

Copy link
Copy Markdown
Member

It looks like your unit test coverage is too low. This is likely due to lack of tests explicitly covering the evaluation details metadata

@tcarrio tcarrio changed the title feat: ✨ expose OpenFeatuer flag metadata feat: expose OpenFeature flag metadata Jul 26, 2026
vi-verrone added a commit to vi-verrone/openfeature-php-sdk that referenced this pull request Jul 27, 2026
Signed-off-by: vi-verrone vi.verrone@gmail.com

Resolve issue open-feature#180

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unit/ResolutionDetailsMetadataTest.php (1)

35-42: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover 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 explicit withMetadata(null) assignment.

  • tests/unit/ResolutionDetailsMetadataTest.php#L35-L42: allow nullable metadata or add a dedicated withMetadata(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

📥 Commits

Reviewing files that changed from the base of the PR and between 434a497 and 0ccfd28.

📒 Files selected for processing (2)
  • tests/unit/EvaluationDetailsMetadataTest.php
  • tests/unit/ResolutionDetailsMetadataTest.php

Comment thread tests/unit/EvaluationDetailsMetadataTest.php
vi-verrone and others added 5 commits July 27, 2026 06:10
…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>
@vi-verrone
vi-verrone force-pushed the feat/expose-flag-metadata-with-ResolutionDetailBuilder branch from 740d086 to 2c4955d Compare July 27, 2026 04:12
@vi-verrone
vi-verrone requested a review from tcarrio July 27, 2026 04:18
@vi-verrone

Copy link
Copy Markdown
Author

@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>
@vi-verrone

Copy link
Copy Markdown
Author

@tcarrio let me know if the PR can be validated and eventually merged, or if there is something more to be added/changed/handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants