Skip to content

fix: Refactor error handling and improve documentation#417

Merged
askpt merged 11 commits into
mainfrom
askpt/issue416
Apr 14, 2025
Merged

fix: Refactor error handling and improve documentation#417
askpt merged 11 commits into
mainfrom
askpt/issue416

Conversation

@askpt
Copy link
Copy Markdown
Member

@askpt askpt commented Apr 5, 2025

Signed-off-by: André Silva 2493377+askpt@users.noreply.github.com

This PR

This pull request includes updates to the README.md, changes to error handling in OpenFeatureClient, and improvements to the InMemoryProvider and its related tests.

Documentation updates:

  • Added notes and examples to the README.md to improve clarity on logging, transaction context propagators, dependency injection, and custom providers. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Error handling improvements:

  • Removed redundant error logging methods FlagEvaluationError and FlagEvaluationErrorWithDescription in OpenFeatureClient. [1] [2] [3]

InMemoryProvider enhancements:

  • Changed InMemoryProvider to return ResolutionDetails with appropriate error types instead of throwing exceptions for missing flags or type mismatches. [1] [2]

Test updates:

  • Updated tests in OpenFeatureClientTests and InMemoryProviderTests to reflect changes in error handling and ensure proper error types and reasons are returned. [1] [2] [3]

Configuration changes:

  • Modified global.json to update the SDK roll-forward policy from latestMajor to latestFeature.

Related Issues

Fixes #416

Notes

After evaluating the global.json, I noticed the rollForward was way too high for what we should be using. I reduced to latestFeature which is safer and would allow us to change the GitHub Actions to use the version from global.json instead of from declaring it in the action itself.

askpt added 4 commits April 5, 2025 18:50
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Comment thread src/OpenFeature/Providers/Memory/InMemoryProvider.cs
…lag and improve assertions

Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.69%. Comparing base (3c7dca3) to head (e603ffb).
⚠️ Report is 239 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
- Coverage   85.71%   85.69%   -0.02%     
==========================================
  Files          39       39              
  Lines        1603     1601       -2     
  Branches      171      171              
==========================================
- Hits         1374     1372       -2     
  Misses        191      191              
  Partials       38       38              

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

@askpt askpt marked this pull request as ready for review April 5, 2025 18:48
@askpt askpt requested a review from a team as a code owner April 5, 2025 18:48
@askpt askpt enabled auto-merge April 5, 2025 18:49
@askpt askpt requested a review from Copilot April 5, 2025 18:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

test/OpenFeature.Tests/OpenFeatureClientTests.cs:187

  • [nitpick] Consider adding a comment in the test to clarify that error logging is intentionally disabled during flag evaluation to help future maintainers understand this behavior.
mockedLogger.Received(0).IsEnabled(LogLevel.Error);

Comment thread README.md Outdated
Comment thread src/OpenFeature/Providers/Memory/InMemoryProvider.cs
askpt added 2 commits April 6, 2025 16:55
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
@askpt askpt requested a review from Copilot April 6, 2025 16:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/OpenFeature/Providers/Memory/InMemoryProvider.cs:115

  • [nitpick] Consider returning a ResolutionDetails with an appropriate error type for type mismatches instead of throwing an exception, to align the error handling behavior with that of missing flags. If the current behavior is by design, please add documentation explaining the rationale.
throw new TypeMismatchException("flag " + flagKey + " is not of type " + typeof(T));

@askpt askpt requested a review from beeme1mr April 6, 2025 16:06
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
Copy link
Copy Markdown

@kriscoleman kriscoleman left a comment

Choose a reason for hiding this comment

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

changes look good to me

I agree with the change on the flag-not-found. I prefer not to use exceptions to control logic flow; that's an old anti-pattern, and those stack traces have a hidden cost.

Thanks!

:shipit:

@askpt askpt requested review from a team April 9, 2025 17:27
@askpt askpt added this pull request to the merge queue Apr 14, 2025
Merged via the queue into main with commit b0b168f Apr 14, 2025
15 checks passed
This was referenced Dec 19, 2025
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.

[FEATURE] Make error log for flag not found optionally a warning/disabled

5 participants