Skip to content

fix(flagd): Default to correct Port when only Resolver is set#585

Merged
askpt merged 5 commits intoopen-feature:mainfrom
kylejuliandev:ensure-flagd-port-is-set-correctly
Feb 24, 2026
Merged

fix(flagd): Default to correct Port when only Resolver is set#585
askpt merged 5 commits intoopen-feature:mainfrom
kylejuliandev:ensure-flagd-port-is-set-correctly

Conversation

@kylejuliandev
Copy link
Contributor

This PR

As part of #576 I'm adding support for the config.feature tests. I noticed one failing test which was the following:

  @in-process
  Scenario Outline: Default Config In-Process
    Given an option "resolver" of type "ResolverType" with value "in-process"
    When a config was initialized
    Then the option "<option>" of type "<type>" should have the value "<default>"
    Scenarios:
      | option | type    | default |
      | port   | Integer | 8015    |

We aren't defaulting the port to 8015 if only the resolver is set. This is a change in behaviour but I think it's warranted as it's likely a source of confusion for developers.

I've also used this opportunity to remove an internal constructor on the FlagdConfig class and updated all the tests to use the builder pattern - which is the only way devs can configure Flagd. This lays the foundation for addressing #478.

Related Issues

Notes

Follow-up Tasks

How to test

Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kylejuliandev, 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 addresses a configuration inconsistency in the flagd provider by ensuring the correct default port is applied when using the in-process resolver. It also significantly refactors the FlagdConfig class to exclusively use a builder pattern for initialization, enhancing the API's robustness and setting the stage for future improvements.

Highlights

  • Default Port Fix for In-Process Resolver: Corrected an issue where the flagd provider was not defaulting to port 8015 when only the in-process resolver type was specified, aligning with expected behavior.
  • Enforced Builder Pattern for FlagdConfig: Removed direct constructors for FlagdConfig, requiring all configurations to be built using the FlagdConfigBuilder for improved consistency and maintainability.
  • URI-based Builder Initialization: Added a new internal static Builder(Uri uri) method to FlagdConfig to facilitate creating a builder instance pre-populated from a URI.
Changelog
  • src/OpenFeature.Contrib.Providers.Flagd/FlagdConfig.cs
    • Introduced an internal static Builder(Uri uri) method to create a FlagdConfigBuilder from a URI, parsing host, port, TLS, and socket path.
    • Modified the default port in the parameterless FlagdConfig constructor to 0, allowing the PreBuild logic to assign the correct default based on resolver type.
    • Removed the internal FlagdConfig(Uri url) constructor, centralizing URI-based configuration through the builder.
    • Implemented a PreBuild() method within FlagdConfigBuilder to dynamically set the default port (8013 for RPC, 8015 for IN_PROCESS) if no port is explicitly configured.
  • src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
    • Updated constructors to utilize the FlagdConfig.Builder() and FlagdConfig.Builder(Uri) methods, ensuring all FlagdProvider instances are initialized via the builder pattern.
  • test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdConfigTest.cs
    • Refactored all existing tests to use the FlagdConfig.Builder() pattern for creating FlagdConfig instances.
    • Added a new parameterized test (WithResolverType_DefaultsPortCorrectly) to explicitly validate the correct default port assignment based on the resolver type.
  • test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs
    • Migrated all FlagdProvider related tests to instantiate FlagdConfig using the new builder pattern.
  • test/OpenFeature.Contrib.Providers.Flagd.Test/Resolver/InProcess/InProcessResolverTests.cs
    • Updated InProcessResolver tests to construct FlagdConfig objects using the builder pattern.
  • test/OpenFeature.Contrib.Providers.Flagd.Test/Resolver/Rpc/RpcResolverTests.cs
    • Updated RpcResolver tests to construct FlagdConfig objects using the builder pattern.
Activity
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 implements defaulting the port based on the resolver type, which is a good improvement for user experience. I've found one bug, which I've detailed in the specific comments.

Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
@kylejuliandev kylejuliandev marked this pull request as ready for review February 4, 2026 00:14
@kylejuliandev kylejuliandev requested review from a team as code owners February 4, 2026 00:14
Copy link
Member

@askpt askpt left a comment

Choose a reason for hiding this comment

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

LGTM. Just a minor comment.

Signed-off-by: Kyle Julian <38759683+kylejuliandev@users.noreply.github.com>
This was referenced Mar 13, 2026
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.

5 participants