Skip to content

fix: carry provider error codes through hooks - #339

Merged
josecolella merged 5 commits into
mainfrom
fix/carry-provider-error-codes
Oct 22, 2026
Merged

josecolella merged 5 commits into
mainfrom
fix/carry-provider-error-codes

Conversation

@josecolella

Copy link
Copy Markdown
Collaborator

Summary

  • Providers can signal an evaluation error with a specific code by raising OpenFeature::SDK::EvaluationError.new(message, error_code: ...) (spec 2.2.7). Any exception that responds to error_code is treated the same way.
  • Error hooks now receive an exception that carries the resolution's error code, instead of a bare StandardError. LoggingHook therefore logs the real code (e.g. FLAG_NOT_FOUND) instead of GENERAL.
  • Part of Spec v0.9.0 compliance #300.

Context for reviewers

  • Before this PR, every exception raised by a provider became GENERAL, and error hooks couldn't see the code.
  • EvaluationError.code_for reads the code defensively. It falls back to GENERAL when 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

  • The contrib OTel MetricsHook derives error.type from exception.class.name. For error resolutions and short-circuits, that value changes from standarderror to openfeature::sdk::evaluationerror. A ruby-sdk-contrib follow-up will switch the hook to the error code.
  • Hooks that raise errors carrying error_code now set details.error_code.
  • A ProviderInitializationError raised from a fetch now reports PROVIDER_FATAL.

What's NOT in this PR

  • Validating error codes against the spec's set. The ResolutionDetails return path doesn't validate either.

🤖 Generated with Claude Code

josecolella and others added 4 commits October 22, 2026 13:44
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>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8dce5bc4-fbe4-4a10-ba09-dac3ce853941
📥 Commits

Reviewing files that changed from the base of the PR and between ac2728d and e9e10a3.

📒 Files selected for processing: 12
  • README.md
  • lib/open_feature/sdk/api.rb
  • lib/open_feature/sdk/client.rb
  • lib/open_feature/sdk/configuration.rb
  • lib/open_feature/sdk/evaluation_error.rb
  • lib/open_feature/sdk/hooks/hook_executor.rb
  • lib/open_feature/sdk/hooks/logging_hook.rb
  • sig/open_feature/sdk/evaluation_error.rbs
  • spec/open_feature/sdk/evaluation_error_spec.rb
  • spec/open_feature/sdk/hooks/hook_executor_spec.rb
  • spec/open_feature/sdk/hooks/logging_hook_spec.rb
  • spec/specification/provider_spec.rb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

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

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

@josecolella
josecolella marked this pull request as ready for review October 22, 2026 22:59
@josecolella
josecolella requested a review from a team as a code owner October 22, 2026 22:59
Copilot AI balanced review requested due to automatic review settings October 22, 2026 22:59
@josecolella josecolella mentioned this pull request Oct 22, 2026
17 tasks done

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 EvaluationError and defensive error-code extraction with a GENERAL fallback.
  • 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
@josecolella
josecolella merged commit b9e586c into main Oct 22, 2026
22 of 24 checks passed
@josecolella
josecolella deleted the fix/carry-provider-error-codes branch October 22, 2026 23:05
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