Repository navigation
fix: carry provider error codes through hooks - #339
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jose Colella <jose.colella@gusto.com>
Read error codes through EvaluationError.code_for, which falls back to GENERAL when the reader raises, so a broken error_code method can't escape a client call (spec 1.4.10). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jose Colella <jose.colella@gusto.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jose Colella <jose.colella@gusto.com>
|
Warning Review limit reachedThis review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry. Next included review available in 55 minutes. View limit details
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #339 +/- ##
=======================================
Coverage 99.50% 99.51%
=======================================
Files 31 32 +1
Lines 807 817 +10
=======================================
+ Hits 803 813 +10
Misses 4 4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in the focused propagation changes and regression coverage; automated checks were not run.
No open issues 🎉
What changed in this PR
This PR preserves provider error codes through the Ruby SDK’s evaluation and hook paths, improving error reporting as part of the specification compliance work tracked in #300.
Changes:
- Adds
EvaluationErrorand defensive error-code extraction with aGENERALfallback. - Carries error codes through evaluations, error hooks, initialization failures, and logging.
- Adds regression coverage, type signatures, and provider documentation.
| File | Description |
|---|---|
spec/specification/provider_spec.rb |
Tests provider exceptions and failing error-code readers. |
spec/open_feature/sdk/hooks/logging_hook_spec.rb |
Tests fallback and end-to-end error-code logging. |
spec/open_feature/sdk/hooks/hook_executor_spec.rb |
Tests error codes passed to error hooks. |
spec/open_feature/sdk/evaluation_error_spec.rb |
Tests the new exception and defensive extraction. |
sig/open_feature/sdk/evaluation_error.rbs |
Defines types for the new exception API. |
README.md |
Documents how providers can signal evaluation errors. |
lib/open_feature/sdk/hooks/logging_hook.rb |
Uses defensive error-code extraction for logging. |
lib/open_feature/sdk/hooks/hook_executor.rb |
Preserves codes in hook exceptions and failure results. |
lib/open_feature/sdk/evaluation_error.rb |
Introduces the code-carrying exception and extraction helper. |
lib/open_feature/sdk/configuration.rb |
Safely extracts initialization error codes. |
lib/open_feature/sdk/client.rb |
Preserves codes from provider exceptions. |
lib/open_feature/sdk/api.rb |
Loads the new exception class. |
Review effort: Balanced
…ror-codes Signed-off-by: Jose Colella <jose.colella@gusto.com> # Conflicts: # lib/open_feature/sdk/configuration.rb
Summary
OpenFeature::SDK::EvaluationError.new(message, error_code: ...)(spec 2.2.7). Any exception that responds toerror_codeis treated the same way.StandardError.LoggingHooktherefore logs the real code (e.g.FLAG_NOT_FOUND) instead ofGENERAL.Context for reviewers
GENERAL, and error hooks couldn't see the code.EvaluationError.code_forreads the code defensively. It falls back toGENERALwhen the code is missing or nil, or when its reader raises, so client calls never raise (1.4.10). The client, the hook executor, the init path and the logging hook all use it.Behavior changes worth noting
MetricsHookderiveserror.typefromexception.class.name. For error resolutions and short-circuits, that value changes fromstandarderrortoopenfeature::sdk::evaluationerror. A ruby-sdk-contrib follow-up will switch the hook to the error code.error_codenow setdetails.error_code.ProviderInitializationErrorraised from a fetch now reportsPROVIDER_FATAL.What's NOT in this PR
ResolutionDetailsreturn path doesn't validate either.🤖 Generated with Claude Code