Skip to content

Conversation

@thomaspoignant
Copy link
Member

Description

This PR fixes issue #1618 where there was unreachable code in the EvaluationService class. The code to throw a FlagNotFoundError when a flag is not found was unreachable because it came after an early return statement.

Changes

  • Moved the FLAG_NOT_FOUND check before the general error handling in EvaluationService.getEvaluation()
  • This makes the FlagNotFoundError exception reachable when a flag is not found
  • Added comprehensive unit tests to validate the fix

Testing

  • Added unit tests that verify:
    • FlagNotFoundError is thrown when flag is not found
    • Other error codes still return error responses (regression test)
    • Successful evaluations continue to work correctly

All tests pass successfully.

Fixes #1618

- Move FLAG_NOT_FOUND check before general error handling in EvaluationService
- This makes the FlagNotFoundError exception reachable when a flag is not found
- Add unit tests to validate the fix

Fixes #1618

Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @thomaspoignant, 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 a critical bug in the go-feature-flag provider where the FlagNotFoundError was never thrown, leading to incorrect error reporting. The core change involves reordering the error handling logic within the EvaluationService to ensure that the specific flag not found error is correctly identified and propagated. This enhancement improves the robustness and accuracy of error handling in the feature flag evaluation process.

Highlights

  • Unreachable Code Fix: Corrected an issue in the EvaluationService where the FlagNotFoundError was unreachable due to an early return statement.
  • Error Handling Reordering: The check for FLAG_NOT_FOUND has been moved to occur before general error handling, ensuring that the specific FlagNotFoundError is thrown when a flag is not found.
  • Comprehensive Unit Tests: New unit tests have been added to validate the fix, cover other error codes, and confirm that successful evaluations continue to work as expected.
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
Contributor

@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 correctly fixes an unreachable code issue where a FlagNotFoundError would never be thrown. The logic is now corrected to check for FLAG_NOT_FOUND before handling other generic errors. The addition of comprehensive unit tests is excellent, as they validate the fix and cover regression and success cases. I've provided one suggestion to refactor the error handling logic for improved readability and maintainability.

@thomaspoignant thomaspoignant merged commit 95e149e into main Jan 15, 2026
5 checks passed
@thomaspoignant thomaspoignant deleted the fix/gofeatureflag-flag-not-found-unreachable-code branch January 15, 2026 22:15
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.

[gofeatureflag] Unreachable code when flag not found

3 participants