Repository navigation
Conversation
Signed-off-by: Yan Chen <yan8925298@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change to propagate after hook failures from Client::evaluate.
No open issues 🎉
What changed in this PR
Fixes Client::evaluate so an after hook failure returns an error instead of a successful provider result, aligning it with the other evaluation error paths.
Changes:
- Propagates the error returned by a failed
afterhook. - Adds a regression test verifying the returned error and ordered
error/finallyhook calls, including the default value and error reason.
| File | Description |
|---|---|
src/hooks/mod.rs |
Adds regression coverage for an after hook failure. |
src/api/client.rs |
Sets the evaluation result to Err(error) when an after hook fails. |
Review effort: Balanced
EmiRZx
left a comment
There was a problem hiding this comment.
fix confirmed, the new test fails on main at result.is_err() and passes here. the quoted text is requirement 4.4.8, added in open-feature/spec#428, while the description links 4.4.5 and 4.3.7.
|
Thanks for verifying the fix and catching the spec reference, @EmiRZx! Updated the PR description to cite Requirement 4.4.8 (open-feature/spec#428). |
EmiRZx
left a comment
There was a problem hiding this comment.
the description now cites 4.4.8. the fix was already confirmed above, so this looks good to me.
Summary
Per the OpenFeature Hooks Specification (Requirement 4.4.8, added in open-feature/spec#428):
In
Client::evaluate(src/api/client.rs), whenafter_hooksreturnsErr(error)after a successful provider resolution, the method already setsevaluation_details = EvaluationDetails::error_reason(flag_key, T::default()), runserror_hooks, and passes the error details tofinally_hooks— however,resultremainedOk(details), causingget_*_valueandget_*_detailsto returnOk(resolved_value)instead ofErr(error).Changes
src/api/client.rs: Makeresultmutable inClient::evaluateand assignresult = Err(error)whenself.after_hooks(...)fails, matching thebefore_hooksand provider-resolution error paths.src/hooks/mod.rs: Add an// error on after hookunit test case insideerror_hookverifying that when anafterhook fails,errorandfinally(withEvaluationReason::Errorand default value) are invoked andget_bool_valuereturnsErr(...).Verification
assertion failed: result.is_err()atsrc/hooks/mod.rs:684).cargo test: 81 unit tests + 1 doctest pass (1 doc-test ignored).cargo clippy -- -D warningsandcargo fmt --check --all: pass with 0 warnings.