feat: populate event details payload with error_code and message#225
feat: populate event details payload with error_code and message#225josecolella merged 2 commits intomainfrom
Conversation
…5.1.4, 5.1.5) - ProviderStateRegistry now stores event details alongside state, so immediate handlers attached after a provider error can access error_code and message - Extract build_event_details helper in Configuration to include stored details when firing immediate handlers - Add spec tests for Requirements 5.1.4 (error message) and 5.1.5 (error code), including immediate handler scenario Closes #210 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jose Colella <jose.colella@gusto.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the OpenFeature SDK's event handling mechanism by ensuring that Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively adds support for populating event details in PROVIDER_ERROR events, ensuring that handlers can access error context even when attached after the fact. The implementation is solid, and the new tests provide good coverage for the specified requirements. I have a couple of suggestions to enhance test reliability and improve code conciseness.
spec/specification/events_spec.rb
Outdated
| allow(provider).to receive(:init).and_raise("Delayed failure") | ||
|
|
||
| OpenFeature::SDK.set_provider(provider) | ||
| sleep(0.01) # Wait for async init to complete |
There was a problem hiding this comment.
Using a fixed-duration sleep for synchronizing with asynchronous operations can lead to flaky tests, especially in slower CI/CD environments. A more robust approach is to poll until the desired state is reached.
sleep(0.001) until OpenFeature::SDK.configuration.provider_state(provider) == OpenFeature::SDK::ProviderState::ERRORUse set_provider_and_wait with rescue instead of sleep(0.01) to deterministically wait for async provider init to complete. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jose Colella <jose.colella@gusto.com>
Summary
ProviderStateRegistrynow stores event details (error_code, message, flags_changed, etc.) alongside provider state, so immediate handlers attached after a provider enters ERROR state can access the full error contextConfiguration#run_immediate_handlernow includes stored details viabuild_event_detailshelper — previously only sent{provider_name: ...}Closes #210
Spec References
This completes Phase 1 (all MUST/Stable requirements) of the spec compliance roadmap: #220
Test plan
bundle exec rspec spec/specification/events_spec.rb— 14 examples, 0 failuresbundle exec rspec— 351 examples, 0 failuresbundle exec standardrb— no offenses🤖 Jose's AI agent