Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add evaluation details to finally hook stage #335

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

askpt
Copy link
Member

@askpt askpt commented Dec 20, 2024

Add evaluation details to the finally hook stage

This pull request includes several changes to improve the handling of flag evaluation details and error handling in the OpenFeature library. The most important changes include modifying hook methods to accept FlagEvaluationDetails as a parameter, updating the EvaluateFlagAsync method to handle provider errors more gracefully, and adjusting the corresponding unit tests to reflect these changes.

Related Issues

Fixes #328

Notes

Improvements to Hook Methods:

Enhancements to Flag Evaluation:

  • src/OpenFeature/OpenFeatureClient.cs: Updated the EvaluateFlagAsync method to initialize FlagEvaluationDetails in case of provider errors and ensure the FinallyAsync hook is always called with the correct evaluation details. [1] [2] [3]

@askpt askpt linked an issue Dec 20, 2024 that may be closed by this pull request
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.27%. Comparing base (e14ab39) to head (f0e884b).

Files with missing lines Patch % Lines
src/OpenFeature/OpenFeatureClient.cs 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #335      +/-   ##
==========================================
- Coverage   85.30%   85.27%   -0.04%     
==========================================
  Files          36       36              
  Lines        1477     1480       +3     
  Branches      150      151       +1     
==========================================
+ Hits         1260     1262       +2     
  Misses        187      187              
- Partials       30       31       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@askpt askpt marked this pull request as ready for review December 20, 2024 13:41
@askpt askpt requested a review from a team as a code owner December 20, 2024 13:41
throw new ProviderNotReadyException("Provider has not yet completed initialization.");
}
else if (provider.Status == ProviderStatus.Fatal)
{
evaluation = new FlagEvaluationDetails<T>(flagKey, defaultValue, ErrorType.ProviderFatal, Reason.Error, string.Empty, string.Empty);
Copy link
Member

Choose a reason for hiding this comment

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

Won't this be overridden in the catch block?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right! Removed here: 5cedb62

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

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

Could you please add a test to ensure that the evaluation details included in the final stage match what's returned to the user? Here's how requirement 4.3.8 was tested in JS.

https://github.com/open-feature/js-sdk/pull/1087/files#diff-5eb44a4c1dd2a0d07e4b54e1eab5d69c60cc983aad849aeae08567fb85af2b3f

Thank!

Signed-off-by: André Silva <[email protected]>
@askpt
Copy link
Member Author

askpt commented Dec 20, 2024

Could you please add a test to ensure that the evaluation details included in the final stage match what's returned to the user? Here's how requirement 4.3.8 was tested in JS.

https://github.com/open-feature/js-sdk/pull/1087/files#diff-5eb44a4c1dd2a0d07e4b54e1eab5d69c60cc983aad849aeae08567fb85af2b3f

Thank!

@beeme1mr I added the specification test with: 25af4ba

I hope it is what you were expecting.

Signed-off-by: André Silva <[email protected]>
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.

Add evaluation details to finally hook stage
3 participants