-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Problem
After upgrading from flagsmith 3.10.0 to 3.10.1, enable_local_evaluation=True
no longer works correctly and falls back to making individual API calls for every flag check instead of using local evaluation. This causes a massive increase in request volume.
Impact
- 10x+ increase in API request volume in production
- Instead of 1 environment document request + local evaluation, every
get_environment_flags()
andget_identity_flags()
call makes separate API requests - Defeats the entire purpose of local evaluation (performance and reduced API load)
- Production systems experience a severe load increase
Root Cause
The issue occurs when the environment document fails to load due to validation errors. The update_environment()
method silently catches these errors, leaving self._environment=None
. This causes the local evaluation condition to always fail:
# In get_environment_flags():
if (self.offline_mode or self.enable_local_evaluation) and self._environment: # ← self._environment is None!
return self._get_environment_flags_from_document() # Never reached
return self._get_environment_flags_from_api() # Always makes API calls instead
Steps to Reproduce
- Initialize Flagsmith client with
enable_local_evaluation=True
- Use any custom API URL or environment that has slightly different response format
- Call
get_environment_flags()
orget_identity_flags()
repeatedly - Expected: 1 environment document request + local evaluation
- Actual: Every flag check makes a separate API request
- You'll see silent "Error updating environment" messages while requests keep hitting your API.
Changes in v3.10.1 that caused this
- PR chore: replacing-deprecated-methods #143 introduced new evaluation methods using
engine.get_evaluation_result()
- Stricter validation that fails on some environment document formats
- Silent error handling masks validation failures
- When environment loading fails, local evaluation completely stops working
PotHixemyller
Metadata
Metadata
Assignees
Labels
No labels