Skip to content

Conversation

@Zaimwa9
Copy link

@Zaimwa9 Zaimwa9 commented Nov 21, 2025

This PR

This PR introduces the flagsmith rust provider

Related Issues

Flagsmith related issue

Notes

As per an experiment using IA toolings, the code implementation has been 90% done by Claude. Although I have thoroughly supervised and review every step of the process.

Interesting files to grasp the context:
context.md
README.md
At flagsmith, we decided to leave all the working files for complete transparency.

Follow-up Tasks

How to test

cargo test -p open-feature-flagsmith

Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @Zaimwa9, 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 integrates Flagsmith as a new feature flag provider for the OpenFeature Rust SDK. It allows Rust applications to dynamically evaluate feature flags from Flagsmith, supporting various data types and evaluation contexts. The implementation includes options for local evaluation, robust error handling, and clear documentation, making it a comprehensive solution for feature management within the OpenFeature ecosystem.

Highlights

  • New Flagsmith Provider: Introduces a new Flagsmith provider for the OpenFeature Rust SDK, enabling integration with Flagsmith for feature flag management.
  • Comprehensive Flag Type Support: The provider supports all five OpenFeature flag types: boolean, string, integer, float, and structured (JSON) values.
  • Flexible Evaluation Modes: Supports both environment-level flag evaluation (without targeting) and identity-specific evaluation (with targeting key and traits), automatically converting OpenFeature context to Flagsmith traits.
  • Local Evaluation Capability: Includes support for local evaluation mode, which can improve performance and enable offline functionality, requiring a server-side environment key.
  • Robust Error Handling: Implements comprehensive error handling and mapping, translating Flagsmith-specific errors to OpenFeature error codes like FlagNotFound, ProviderNotReady, TypeMismatch, and ParseError.
  • Detailed Documentation and Examples: The new provider comes with a dedicated README, CHANGELOG, and usage examples to facilitate adoption and understanding.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@Zaimwa9 Zaimwa9 changed the title Feat/add flagsmith provider feat: add-flagsmith-provider-crate Nov 21, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR introduces a new Flagsmith provider for the OpenFeature Rust SDK. The implementation is comprehensive, covering all required evaluation types, context mapping, and error handling. The use of a FlagsmithClient trait for mockability and the extensive test suite are excellent.

I've identified a few areas for improvement:

  • Error Handling: The current mechanism for detecting a "Flag Not Found" error relies on string matching, which is brittle.
  • Code Duplication: There's significant code duplication across the resolve_* methods that could be refactored.
  • Context Conversion: Struct values in the evaluation context are silently dropped during conversion to Flagsmith traits.
  • Documentation: Some code examples in the README are not compilable.
  • Project Files: The context.md file seems to be an artifact of the development process and might not be intended for inclusion in the repository.
  • Configuration: The crate's Rust edition is 2021, while the project seems to be moving towards 2024.

Overall, this is a great contribution. Addressing these points will improve the provider's robustness and maintainability.

Zaimwa9 and others added 11 commits November 21, 2025 11:42
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zaimwa9 <wadii.zaim@gmail.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
…-sdk-contrib into feat/add-flagsmith-provider
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zaimwa9 <wadii.zaim@gmail.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
…-sdk-contrib into feat/add-flagsmith-provider
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
@Zaimwa9
Copy link
Author

Zaimwa9 commented Nov 21, 2025

@gemini-code-assist. Are you able to provide a new review ?

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new open-feature-flagsmith provider crate, which integrates the Flagsmith SDK with OpenFeature for Rust. The implementation is comprehensive, covering all OpenFeature flag types, environment and identity-based evaluation, local evaluation mode, and extensive testing. The code is well-structured, documented, and makes good use of Rust's features, including a trait for mocking the Flagsmith client for tests.

My review focuses on improving the robustness and maintainability of the library. I've suggested a few changes:

  • Specifying explicit tokio features in Cargo.toml instead of using full to reduce the dependency footprint for consumers.
  • Correcting a markdown formatting issue in the README.md to improve documentation readability.
  • Enhancing a code example in the README.md to make it self-contained and easier for users to understand.
  • Adding a missing type check in the resolve_struct_value function to improve robustness and align it with the other resolver functions.

Overall, this is a great contribution and the new provider is a valuable addition to the OpenFeature ecosystem.

Zaimwa9 and others added 5 commits November 21, 2025 15:56
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zaimwa9 <wadii.zaim@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Zaimwa9 <wadii.zaim@gmail.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
@Zaimwa9
Copy link
Author

Zaimwa9 commented Nov 21, 2025

@gemini-code-assist, new review please

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new crate for the Flagsmith OpenFeature provider. The implementation is of high quality, demonstrating a strong understanding of both OpenFeature and asynchronous Rust principles, especially with the correct use of spawn_blocking for synchronous SDK calls. The code is well-structured, and the inclusion of a mockable client trait and comprehensive tests (unit, integration, and error-specific) is excellent. I've added a few review comments with suggestions to enhance consistency in type handling, remove a piece of unused code, and improve the handling of null values in JSON structures. Overall, this is a solid contribution.

Signed-off-by: wadii <wadii.zaim@flagsmith.com>
@beeme1mr
Copy link
Member

Hey @Zaimwa9, I've pinged Todd to see if he can help review. We'll only be able to review from an OpenFeature perspective as Rust is not an area of expertise for either of us.

/// ```
#[instrument(skip(environment_key, options))]
pub async fn new(
environment_key: String,
Copy link
Member

Choose a reason for hiding this comment

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

We might benefit from use of Secret<String> here, so this can't really be logged.

@toddbaert toddbaert self-requested a review November 26, 2025 17:33
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

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

Approving from a provider/spec perspective, with one code recommendation.

Deps look good, docs look good.

Please also merge/rebase main and add a component owners entry as in Ruby: https://github.com/open-feature/rust-sdk-contrib/blob/main/.github/component_owners.yml

@Zaimwa9
Copy link
Author

Zaimwa9 commented Nov 27, 2025

Thanks @toddbaert, will do. I'll be waiting for an internal review by next week before moving forward

Signed-off-by: wadii <wadii.zaim@flagsmith.com>
toddbaert added a commit to open-feature/community that referenced this pull request Nov 27, 2025
@Zaimwa9 recently added open-feature/ruby-sdk-contrib#68 and open-feature/rust-sdk-contrib#82 flagsmith providers.

@Zaimwa9 please 👍 or approve this PR if you are interested in joining the org.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Copy link

@gagantrivedi gagantrivedi left a comment

Choose a reason for hiding this comment

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

looks good

@Zaimwa9
Copy link
Author

Zaimwa9 commented Dec 3, 2025

@toddbaert , Gagan is part of flagsmith team with knowledge in Rust. I believe we are ready to move forward.
Thanks for your help!

Signed-off-by: wadii <wadii.zaim@flagsmith.com>
Copy link
Contributor

@jbovet jbovet left a comment

Choose a reason for hiding this comment

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

nice work on this @Zaimwa9 ,thanks for the contribution!

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.

6 participants