Skip to content

Conversation

@kushbatra
Copy link

This PR

This PR fixes the issue where FlagsmithProvider.getDoubleDetails fails to parse flag values returned as strings (e.g., "42.42") from Flagsmith. Previously, the provider expected a java.lang.Double and returned an error if the value was a string. With this change, the provider will attempt to parse string values to Double when evaluating double flags, ensuring compatibility with Flagsmith environments that store numeric values as strings. Similar case is handled for Integer as well.

Related Issues

Fixes #1557

Notes

Follow-up Tasks

How to test

@gemini-code-assist
Copy link

Summary of Changes

Hello @kushbatra, 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 resolves an issue in the Flagsmith provider where numeric flag values, when returned as strings, were not correctly converted to their expected Double or Integer types. The changes enhance the convertValue utility method to perform robust string-to-numeric parsing, ensuring greater compatibility and preventing runtime errors when integrating with Flagsmith environments that may store numeric values as strings. Additionally, comprehensive unit tests have been introduced to cover these new conversion scenarios and error conditions.

Highlights

  • Type Conversion Fix: The FlagsmithProvider now correctly handles numeric flag values (Double and Integer) that are returned as strings from Flagsmith, preventing TypeMismatchError.
  • Enhanced convertValue Method: The convertValue method in FlagsmithProvider.java has been updated to explicitly parse string representations into Double or Integer types when the expected type is numeric.
  • Robust Error Handling: Improved error handling for type mismatches, including specific TypeMismatchError exceptions for unparseable strings during numeric conversion.
  • Comprehensive Unit Tests: New parameterized tests and specific error-case tests have been added to FlagsmithProviderTest.java to validate the enhanced convertValue logic for various input types and invalid string formats.
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.

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 successfully addresses an issue where string representations of numbers from Flagsmith were not correctly converted to Double or Integer types. The changes in FlagsmithProvider introduce parsing logic for these cases, and the new tests in FlagsmithProviderTest effectively validate this new functionality. My review includes a couple of suggestions to refactor the new code to improve maintainability by reducing duplication in both the provider logic and the tests.

@kushbatra
Copy link
Author

I’ve raised this PR to address the feedback from PR-1617. After several review iterations, I’ve resolved the Gemini-related comments and ensured the main logic and additional use cases are implemented. If there are further suggestions, I’d be happy to consider them in a separate PR or issue. Thank you for your ongoing feedback and support!

Copy link
Contributor

@chrfwow chrfwow 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! There are some code format issues, which can be fixed with mvn spotless:apply

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.

[Flagsmith] getDoubleDetails expects a java.lang.Double from the SDK

8 participants