Skip to content

Feature flag provider index offset strategy#737

Open
linglingye001 wants to merge 2 commits into
mainfrom
linglingye/migrate-feature-flags
Open

Feature flag provider index offset strategy#737
linglingye001 wants to merge 2 commits into
mainfrom
linglingye/migrate-feature-flags

Conversation

@linglingye001
Copy link
Copy Markdown
Member

@linglingye001 linglingye001 commented May 22, 2026

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:

  • 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

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.
@linglingye001 linglingye001 marked this pull request as ready for review May 27, 2026 06:49
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