Skip to content

Conversation

@petruki
Copy link
Member

@petruki petruki commented Oct 5, 2025

This pull request adds support for local criteria evaluation in the Switcher client, allowing feature flag checks to be performed using locally loaded snapshots instead of requiring remote API calls. It introduces a new resolver for local logic, improves error handling, and updates the data type definitions for stricter type safety. Comprehensive tests are also added to verify the new local evaluation logic.

Local criteria evaluation and resolver:

  • Introduced the Resolver class in lib/resolver.py to evaluate feature flags locally using a loaded snapshot, including checks for domain, group, and config activation. Raises a custom LocalCriteriaError for missing or invalid data.
  • Updated Switcher in switcher.py to route criteria checks through the new local resolver when the context specifies local evaluation, falling back to remote checks otherwise. [1] [2] [3]

Error handling improvements:

  • Added a new LocalCriteriaError exception for local evaluation errors, ensuring clear error reporting when snapshots are missing or keys are not found.

Type safety and data model updates:

  • Made fields in Domain, Group, Config, StrategyConfig, and Relay non-optional and provided default values when parsing JSON, improving type safety and preventing issues with missing data. [1] [2] [3] [4] [5]
  • Added static methods to ResultDetail for easily creating success and disabled results.

@petruki petruki self-assigned this Oct 5, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 5, 2025

@petruki petruki merged commit 993b2c6 into master Oct 5, 2025
13 checks passed
@petruki petruki deleted the staging branch October 5, 2025 00:56
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