Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request introduces support for setting a default result when feature flag criteria evaluation fails, both for local and remote strategies. This ensures that the application can gracefully handle errors by returning a predefined result instead of raising exceptions, and provides improved error notification and logging. The PR also updates documentation and adds comprehensive tests for these new behaviors.
Default result support and error handling:
default_resultmethod to theSwitcherclass, allowing users to specify a fallback result if criteria evaluation fails. The implementation ensures that, in case of errors (e.g., missing config, remote API failure), the default result is returned and the error is logged or notified. (switcher_client/switcher_data.py[1] [2];switcher_client/switcher.py[3]_get_default_result_or_raisehelper to encapsulate fallback logic and error notification when criteria checks fail. (switcher_client/switcher.pyswitcher_client/switcher.pyR93-R125)createmethod toResultDetailfor easier instantiation in fallback scenarios. (switcher_client/lib/types.pyswitcher_client/lib/types.pyR9-R12)Documentation updates:
README.mdto demonstrate chaining of validation strategies, including the newdefault_resultandthrottlemethods for robust feature control. (README.mdREADME.mdL212-R220)Testing improvements:
default_resultis correctly returned on local and remote evaluation failures, and that error notifications are triggered as expected. (tests/test_switcher_local.py[1] [2] [3];tests/test_switcher_remote.py[4] [5]