Skip to content

feat: migrate to new flag engine with context value support#39

Merged
gagantrivedi merged 5 commits intomainfrom
feat/use-new-engine
Nov 18, 2025
Merged

feat: migrate to new flag engine with context value support#39
gagantrivedi merged 5 commits intomainfrom
feat/use-new-engine

Conversation

@gagantrivedi
Copy link
Member

Summary

This PR upgrades the SDK to use the new flag engine with context value support and includes critical error handling improvements and validation enhancements.

Changes

🚀 Engine Upgrade

  • Migrated to new flagsmith-flag-engine architecture in order to support context values
  • Fixed get_environment_flags() to properly ignore segment overrides
  • Updated evaluation context handling for better separation of environment vs identity evaluation

🐛 Critical Bug Fixes

  • Fixed swapped error messages: FlagsmithClientError and FlagsmithAPIError were displaying incorrect messages
  • Fixed background thread crashes: Replaced .unwrap() with proper error handling in polling thread to prevent silent failures
  • Added graceful degradation: When environment updates fail, the client now logs warnings and falls back to API mode instead of crashing

✨ Enhancements

  • Server key validation: Added validation to ensure local evaluation mode only accepts server-side keys (starting with ser.)
  • std::error::Error trait: Implemented standard error trait for better ecosystem integration with anyhow, eyre, and other error handling crates
  • Improved resilience: Background polling thread now retries on failures instead of dying silently

🧪 Tests

  • Added integration tests for segment filtering in environment flags
  • Added tests for identity segment membership
  • Updated test fixtures with multivariate feature support

Breaking Changes

None - all changes are backward compatible

Related Issues

Fixes issues with:

  • Silent background thread failures causing stale data
  • Confusing error messages showing wrong error types

@gagantrivedi gagantrivedi requested a review from a team as a code owner November 17, 2025 11:10
@gagantrivedi gagantrivedi requested review from a team, Zaimwa9, emyller and khvn26 and removed request for a team and khvn26 November 17, 2025 11:10
Copy link

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, couple of questions. Even though I'm positively surprise by the ease of reading/manipulating Rust, I might not be the best suited one for syntax/language specifics

Copy link

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks for your answers. To me it's good like this 👍

@gagantrivedi gagantrivedi merged commit 19a235b into main Nov 18, 2025
1 check passed
@emyller emyller deleted the feat/use-new-engine branch November 18, 2025 18:36
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