Feature flag provider index offset strategy#737
Open
linglingye001 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an index-offset strategy for Microsoft-schema feature flags emitted by the Azure App Configuration provider to avoid array-index collisions when multiple providers are registered on the same IConfigurationBuilder. It also adds a new, opt-in ConfigureFeatureFlags API surface (with companion option types) and expands unit coverage around provider ordering/offset behavior.
Changes:
- Derive a per-provider feature flag index offset (based on prior Azure App Configuration sources) and apply it when emitting Microsoft-schema feature flags.
- Add warning logging when a single provider emits feature flags at/over the per-provider stride limit.
- Add new “opt-in” feature flag configuration APIs (
ConfigureConnection,ConfigureFeatureFlags) and accompanying option types, plus comprehensive unit tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Tests.AzureAppConfiguration/Unit/FeatureManagementTests.cs | Adds regression/unit tests validating index offsets across 1–3 providers and ConfigureFeatureFlags behavior/validation. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureManagementKeyValueAdapter.cs | Applies FeatureFlagIndexOffset when emitting Microsoft-schema flags; adds stride overflow warning behavior. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureManagementConstants.cs | Introduces FeatureFlagIndexStride constant used for per-provider offset spacing. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureFlagRefreshOptions2.cs | Adds new refresh options type for the new ConfigureFeatureFlags API. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureFlagOptions2.cs | Adds new feature flag options type (selectors + refresh configuration) for ConfigureFeatureFlags. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationSource.cs | Computes default index offset for a source based on how many prior App Configuration sources exist on the builder. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationOptions.cs | Adds FeatureFlagIndexOffset, new connection aliases, and ConfigureFeatureFlags opt-in configuration flow. |
| src/Microsoft.Extensions.Configuration.AzureAppConfiguration/AzureAppConfigurationExtensions.cs | Counts existing App Configuration sources when adding a new source to drive offset derivation. |
Comment on lines
+29
to
+32
| if (options.FeatureFlagIndexOffset == 0 && priorAppConfigSourceCount > 0) | ||
| { | ||
| options.FeatureFlagIndexOffset = priorAppConfigSourceCount * FeatureManagementConstants.FeatureFlagIndexStride; | ||
| } |
Comment on lines
+2473
to
+2477
| public void FeatureFlagIndexOffset_DuplicateFlagIds_LaterProviderWins() | ||
| { | ||
| // Document and lock in the "new flag wins on duplicate" behavior that customers rely | ||
| // on during migration. Because the second provider's indices come after the first's, | ||
| // the Feature Management library's LastOrDefault resolution picks the second. |
Comment on lines
+162
to
+163
| // Warn once when this provider has emitted more flags than the offset stride can | ||
| // accommodate; further flags will collide with the next provider's offset slot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces an index-offset strategy for Microsoft-schema feature flags emitted by the Azure App Configuration provider to avoid array-index collisions when multiple providers are registered on the same
IConfigurationBuilder.Changes: