Skip to content

Convert config key to map<string, String> and provide custom unmarsha…#2523

Open
clun wants to merge 1 commit into
mainfrom
clun/issue-2506
Open

Convert config key to map<string, String> and provide custom unmarsha…#2523
clun wants to merge 1 commit into
mainfrom
clun/issue-2506

Conversation

@clun

@clun clun commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What This PR Does

This PR resolves a configuration mismatch when setting API feature flags via environment variables.

Previously, feature flags whose enum names contained underscores (for example, BILLING_EVENTS_LOGGING) could not be configured correctly through environment variables. This occurred because SmallRye Config automatically translates underscores (_) to dots (.), which conflicted with the existing enum-to-string conversion logic.

By changing feature flag configuration keys from enum types to strings at the configuration boundary and performing explicit conversion at runtime, both property-based and environment-variable-based configuration now work consistently.

Related Issue

Fixes #2506

Changes

1. FeaturesConfig.java

  • Changed the configuration mapping from:

    Map<ApiFeature, String> flags()

    to:

    Map<String, String> flags()
  • Added comprehensive JavaDoc documentation covering:

    • Configuration using property files
    • Configuration using environment variables
    • SmallRye Config's automatic underscore-to-dot translation behavior
  • Added configuration examples for both approaches

2. ApiFeatures.java

  • Added marshallFromConfig(Map<String, String>) to convert configuration keys to ApiFeature enums
  • Added findFeatureByName(String) helper method to support kebab-case feature flag lookup
  • Updated the constructor to accept Map<String, String> and perform explicit marshalling
  • Added robust validation and error handling that:
    • Detects invalid feature flag names
    • Provides clear, actionable error messages
    • Lists all supported feature flag names

3. BillingTest.java

  • Updated test mocks to use string-based feature flag keys (for example, "billing-events-logging") instead of enum values
  • Verified configuration values take precedence over request headers
  • Verified request headers can enable features when configuration is not set
  • Preserved all existing test coverage

Configuration Examples

Property File (application.yaml)

stargate.feature.flags.lexical: true
stargate.feature.flags.billing-events-logging: true

Environment Variables

export STARGATE_FEATURE_FLAGS_LEXICAL=true
export STARGATE_FEATURE_FLAGS_BILLING_EVENTS_LOGGING=true

Checklist

@clun clun requested a review from a team as a code owner July 1, 2026 13:39
@clun clun requested a review from amorton July 1, 2026 13:41
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📈 Unit Test Coverage Delta vs Main Branch

Metric Value
Main Branch 52.97%
This PR 52.99%
Delta 🟢 +0.02%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Unit Test Coverage Report

Overall Project 52.99% -0.02% 🍏
Files changed 75.76% 🍏

File Coverage
ApiFeatures.java 81.71% -13.71% 🍏

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📈 Integration Test Coverage Delta vs Main Branch (dse69-it)

Metric Value
Main Branch 71.43%
This PR 71.43%
Delta 🟢 +0.00%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (dse69-it)

Overall Project 71.43% -0.02% 🍏
Files changed 73.74% 🍏

File Coverage
ApiFeatures.java 77.14% -14.86% 🍏

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📈 Integration Test Coverage Delta vs Main Branch (hcd-it)

Metric Value
Main Branch 72.75%
This PR 72.75%
Delta 🟢 +0.00%
✅ Coverage improved!

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Integration Test Coverage Report (hcd-it)

Overall Project 72.75% -0.02% 🍏
Files changed 73.74% 🍏

File Coverage
ApiFeatures.java 73.71% -14.86% 🍏

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.

ApiFeatures does not support setting via ENV vars

1 participant