Skip to content

Conversation

@Tmakinde
Copy link
Contributor

@Tmakinde Tmakinde commented Sep 10, 2025

Overview

This pull request refactors the client creation logic in OpenFeatureAPI to improve testability and resilience.

  • Introduces a dedicated resolveClient method, which encapsulates client instantiation logic.

  • Ensures that failures during client resolution are handled gracefully by returning a NoOpClient.

  • Adds a testing dependency to allow mocking of final classes, enabling comprehensive test coverage without altering production code.

@Tmakinde Tmakinde requested a review from tcarrio as a code owner September 10, 2025 12:56
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Tmakinde, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the client creation logic within the OpenFeature API to enhance testability and robustness. It introduces a dedicated method for resolving clients, which allows for better handling of failure scenarios by returning a NoOpClient. This change is supported by a new testing dependency that enables mocking of final classes, ensuring comprehensive test coverage for these new behaviors.

Highlights

  • New Dependency for Testing: The dg/bypass-finals library has been added to composer.json to facilitate testing of final classes.
  • Client Resolution Refactoring: A new resolveClient method was introduced in OpenFeatureAPI.php to centralize the creation of OpenFeatureClient instances, improving modularity and testability.
  • Enhanced Client Error Handling Test: A new unit test was added to OpenFeatureAPITest.php to ensure that a NoOpClient is returned when the client resolution process encounters an exception, leveraging the new dg/bypass-finals dependency for mocking.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.75%. Comparing base (2123274) to head (72d8848).
⚠️ Report is 21 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #157      +/-   ##
============================================
+ Coverage     95.19%   96.75%   +1.56%     
- Complexity      227      228       +1     
============================================
  Files            40       40              
  Lines           583      586       +3     
============================================
+ Hits            555      567      +12     
+ Misses           28       19       -9     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a refactoring to extract client creation into a dedicated resolveClient method within OpenFeatureAPI, and adds a new test case to ensure a NoOpClient is returned if client resolution fails. The changes improve testability. My review includes a few suggestions:

  • The implementation to return a NoOpClient on failure is missing in the getClient method's error handling, which will cause the new test to fail.
  • The visibility of the new resolveClient method could be restricted for better encapsulation.
  • There's a minor correction needed in a test file's type hint.
    Overall, this is a good step towards making the client resolution more robust, and with the suggested changes, it will be complete.

Copy link
Member

@tcarrio tcarrio left a comment

Choose a reason for hiding this comment

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

A styling issue, and one necessary change, granted mockery should support it. Otherwise, this looks good to me. Once the changes are pushed, I can approve.

Thank you for your contribution @Tmakinde 🙏

@Tmakinde Tmakinde force-pushed the feat/test-no-up-client-default branch 2 times, most recently from 88e3496 to 427c078 Compare September 10, 2025 13:48
@Tmakinde Tmakinde changed the title [DRAFT] Feat/test no up client default test: Write test for OpenfeatureAPI to return No-op client when OpenfeatureClient is unresolvable Sep 10, 2025
@Tmakinde Tmakinde force-pushed the feat/test-no-up-client-default branch from 427c078 to 6399754 Compare September 10, 2025 13:52
Signed-off-by: tmakinde <makindet74@gmail.com>
Signed-off-by: tmakinde <makindet74@gmail.com>
…atureClient fail

Signed-off-by: tmakinde <makindet74@gmail.com>
@Tmakinde Tmakinde force-pushed the feat/test-no-up-client-default branch from 6399754 to 72d8848 Compare September 10, 2025 14:00
@Tmakinde
Copy link
Contributor Author

A styling issue, and one necessary change, granted mockery should support it. Otherwise, this looks good to me. Once the changes are pushed, I can approve.

Thank you for your contribution @Tmakinde 🙏

I have fixed all the changes you mentioned. Thank you for the review @tcarrio

@tcarrio tcarrio merged commit 2c4dba8 into open-feature:main Sep 10, 2025
11 checks passed
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.

3 participants