Skip to content

feat: add GCP Parameter Manager OpenFeature provider#1771

Open
mahpatil wants to merge 3 commits intoopen-feature:mainfrom
mahpatil:feat/gcp-parameter-manager
Open

feat: add GCP Parameter Manager OpenFeature provider#1771
mahpatil wants to merge 3 commits intoopen-feature:mainfrom
mahpatil:feat/gcp-parameter-manager

Conversation

@mahpatil
Copy link
Copy Markdown

@mahpatil mahpatil commented Apr 9, 2026

Summary

  • Adds a new OpenFeature provider for GCP Parameter Manager that reads feature flags from GCP Parameter Manager parameters
  • Includes flag caching, value conversion for all OpenFeature types (bool, string, int, double, object), and background polling for updates
  • Adds a sample application under samples/gcp-parameter-manager-sample/ with setup/teardown scripts

Provider Details

  • Package: providers/gcp-parameter-manager
  • Class: GcpParameterManagerProvider
  • Supports all OpenFeature flag types via structured or plain-text parameter values
  • Configurable poll interval and GCP project/location settings

Test plan

  • Unit tests for FlagCache, FlagValueConverter, and GcpParameterManagerProvider
  • Integration test (GcpParameterManagerProviderIntegrationTest) requires a real GCP project — set GCP_PROJECT_ID env var to run
  • Sample app: follow samples/gcp-parameter-manager-sample/README.md to run end-to-end

@mahpatil mahpatil requested a review from a team as a code owner April 9, 2026 05:18
Copy link
Copy Markdown
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 introduces a new OpenFeature provider for Google Cloud Parameter Manager, allowing feature flags to be evaluated from GCP parameters. The provider supports various data types (boolean, string, integer, double, and JSON objects) and includes an in-memory cache for performance. The changes encompass the core provider implementation, configuration options, unit and integration tests, and a sample application demonstrating its usage. Feedback indicates a potential race condition in the FlagCache.get method, suggesting a more robust removal mechanism for expired entries, and points out that the spotbugs-exclusions.xml file contains irrelevant entries that should be removed for clarity.

Adds a new OpenFeature provider for GCP Parameter Manager that enables
reading feature flags from GCP Parameter Manager secrets. Includes the
provider implementation with flag caching, value conversion, unit tests,
integration tests, and a sample application demonstrating usage.

Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
1. Fix race condition in the get method
2. Remove spotbugs exclusions that were copy pasted

Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
@mahpatil mahpatil force-pushed the feat/gcp-parameter-manager branch from c884e5e to 54ba9f2 Compare April 11, 2026 20:41
@aepfli
Copy link
Copy Markdown
Member

aepfli commented Apr 13, 2026

/gemini review

Copy link
Copy Markdown
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 introduces a new OpenFeature provider for Google Cloud Parameter Manager, enabling feature flag management through GCP-native parameters. The implementation includes a thread-safe TTL-based in-memory cache, a converter for handling various data types (including JSON objects), and a sample application with setup scripts. The review feedback suggests correcting dependency versions for SLF4J and Log4j, updating the evaluation reason to accurately reflect the caching mechanism, and ensuring that original exception causes are preserved in error handling.

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.17</version>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The version 2.0.17 for slf4j-api is likely a typo or ahead of the current stable release. The latest stable version is 2.0.16.

Suggested change
<version>2.0.17</version>
<version>2.0.16</version>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.25.0</version>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The version 2.25.0 for log4j-slf4j2-impl is likely a typo. The latest stable version is 2.24.3.

Suggested change
<version>2.25.0</version>
<version>2.24.3</version>

T value = FlagValueConverter.convert(rawValue, targetType);
return ProviderEvaluation.<T>builder()
.value(value)
.reason(Reason.STATIC.toString())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since the provider uses an in-memory cache with a TTL, it is more accurate to return Reason.CACHED instead of Reason.STATIC for evaluations.

Suggested change
.reason(Reason.STATIC.toString())
.reason(Reason.CACHED.toString())

} catch (NotFoundException e) {
throw new FlagNotFoundError("Parameter not found: " + parameterName);
} catch (Exception e) {
throw new GeneralError("Error fetching parameter '" + parameterName + "': " + e.getMessage());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

When throwing a GeneralError due to an exception, it is best practice to include the original cause to aid in debugging.

Suggested change
throw new GeneralError("Error fetching parameter '" + parameterName + "': " + e.getMessage());
throw new GeneralError("Error fetching parameter '" + parameterName + "': " + e.getMessage(), e);

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