Skip to content

Commit 8cac98e

Browse files
authored
App Config Provider - Fix Feature Flag Loading (Azure#39985)
* Stops loading feature flags as configurations * cleaning up a bit * bug fix and new recordings * Update assets.json * formatting
1 parent 07dfffc commit 8cac98e

File tree

4 files changed

+35
-32
lines changed

4 files changed

+35
-32
lines changed

sdk/appconfiguration/azure-appconfiguration-provider/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Release History
22

3-
## 2.0.1 (2025-02-27)
3+
## 2.0.1 (2025-03-07)
44

55
### Bugs Fixed
66

77
* Updates the failure to load from a config store from a debug level log to a warning level log.
88
* Fixes an issue where the stack trace from the azure sdk wasn't being logged on startup.
9+
* Fixes a bug where feature flags could be loaded as configurations.
910

1011
### Other Changes
1112

sdk/appconfiguration/azure-appconfiguration-provider/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/appconfiguration/azure-appconfiguration-provider",
5-
"Tag": "python/appconfiguration/azure-appconfiguration-provider_41f1b04ee9"
5+
"Tag": "python/appconfiguration/azure-appconfiguration-provider_81cf701465"
66
}

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_azureappconfigurationprovider.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
TYPE_CHECKING,
1919
)
2020
from azure.appconfiguration import ( # type:ignore # pylint:disable=no-name-in-module
21+
ConfigurationSetting,
2122
FeatureFlagConfigurationSetting,
2223
SecretReferenceConfigurationSetting,
2324
)
@@ -359,15 +360,7 @@ def refresh(self, **kwargs) -> None: # pylint: disable=too-many-statements
359360
need_refresh, self._refresh_on, configuration_settings = client.refresh_configuration_settings(
360361
self._selects, self._refresh_on, headers=headers, **kwargs
361362
)
362-
configuration_settings_processed = {}
363-
for config in configuration_settings:
364-
key = self._process_key_name(config)
365-
value = self._process_key_value(config)
366-
configuration_settings_processed[key] = value
367-
if self._feature_flag_enabled:
368-
configuration_settings_processed[FEATURE_MANAGEMENT_KEY] = self._dict[
369-
FEATURE_MANAGEMENT_KEY
370-
]
363+
configuration_settings_processed = self._proccess_configurations(configuration_settings)
371364
if need_refresh:
372365
self._dict = configuration_settings_processed
373366
if self._feature_flag_refresh_enabled:
@@ -429,12 +422,7 @@ def _load_all(self, **kwargs):
429422
configuration_settings, sentinel_keys = client.load_configuration_settings(
430423
self._selects, self._refresh_on, headers=headers, **kwargs
431424
)
432-
configuration_settings_processed = {}
433-
for config in configuration_settings:
434-
key = self._process_key_name(config)
435-
value = self._process_key_value(config)
436-
configuration_settings_processed[key] = value
437-
425+
configuration_settings_processed = self._proccess_configurations(configuration_settings)
438426
if self._feature_flag_enabled:
439427
feature_flags, feature_flag_sentinel_keys, used_filters = client.load_feature_flags(
440428
self._feature_flag_selectors, self._feature_flag_refresh_enabled, headers=headers, **kwargs
@@ -473,6 +461,19 @@ def _load_all(self, **kwargs):
473461
is_failover_request = True
474462
raise exception
475463

464+
def _proccess_configurations(self, configuration_settings: List[ConfigurationSetting]) -> Dict[str, Any]:
465+
configuration_settings_processed = {}
466+
for config in configuration_settings:
467+
if isinstance(config, FeatureFlagConfigurationSetting):
468+
# Feature flags are not processed like other settings
469+
continue
470+
key = self._process_key_name(config)
471+
value = self._process_key_value(config)
472+
configuration_settings_processed[key] = value
473+
if self._feature_flag_enabled and FEATURE_MANAGEMENT_KEY in self._dict:
474+
configuration_settings_processed[FEATURE_MANAGEMENT_KEY] = self._dict[FEATURE_MANAGEMENT_KEY]
475+
return configuration_settings_processed
476+
476477
def _process_key_value(self, config):
477478
if isinstance(config, SecretReferenceConfigurationSetting):
478479
return _resolve_keyvault_reference(config, self)

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/aio/_azureappconfigurationproviderasync.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
Union,
2121
)
2222
from azure.appconfiguration import ( # type:ignore # pylint:disable=no-name-in-module
23+
ConfigurationSetting,
2324
FeatureFlagConfigurationSetting,
2425
SecretReferenceConfigurationSetting,
2526
)
@@ -376,15 +377,7 @@ async def refresh(self, **kwargs) -> None: # pylint: disable=too-many-statement
376377
self._selects, self._refresh_on, headers=headers, **kwargs
377378
)
378379
)
379-
configuration_settings_processed = {}
380-
for config in configuration_settings:
381-
key = self._process_key_name(config)
382-
value = await self._process_key_value(config)
383-
configuration_settings_processed[key] = value
384-
if self._feature_flag_enabled:
385-
configuration_settings_processed[FEATURE_MANAGEMENT_KEY] = self._dict[
386-
FEATURE_MANAGEMENT_KEY
387-
]
380+
configuration_settings_processed = await self._proccess_configurations(configuration_settings)
388381
if need_refresh:
389382
self._dict = configuration_settings_processed
390383
if self._feature_flag_refresh_enabled:
@@ -446,12 +439,7 @@ async def _load_all(self, **kwargs):
446439
configuration_settings, sentinel_keys = await client.load_configuration_settings(
447440
self._selects, self._refresh_on, headers=headers, **kwargs
448441
)
449-
configuration_settings_processed = {}
450-
for config in configuration_settings:
451-
key = self._process_key_name(config)
452-
value = await self._process_key_value(config)
453-
configuration_settings_processed[key] = value
454-
442+
configuration_settings_processed = await self._proccess_configurations(configuration_settings)
455443
if self._feature_flag_enabled:
456444
feature_flags, feature_flag_sentinel_keys, used_filters = await client.load_feature_flags(
457445
self._feature_flag_selectors, self._feature_flag_refresh_enabled, headers=headers, **kwargs
@@ -492,6 +480,19 @@ async def _load_all(self, **kwargs):
492480
is_failover_request = True
493481
raise exception
494482

483+
async def _proccess_configurations(self, configuration_settings: List[ConfigurationSetting]) -> Dict[str, Any]:
484+
configuration_settings_processed = {}
485+
for config in configuration_settings:
486+
if isinstance(config, FeatureFlagConfigurationSetting):
487+
# Feature flags are not processed like other settings
488+
continue
489+
key = self._process_key_name(config)
490+
value = await self._process_key_value(config)
491+
configuration_settings_processed[key] = value
492+
if self._feature_flag_enabled and FEATURE_MANAGEMENT_KEY in self._dict:
493+
configuration_settings_processed[FEATURE_MANAGEMENT_KEY] = self._dict[FEATURE_MANAGEMENT_KEY]
494+
return configuration_settings_processed
495+
495496
async def _process_key_value(self, config):
496497
if isinstance(config, SecretReferenceConfigurationSetting):
497498
return await _resolve_keyvault_reference(config, self)

0 commit comments

Comments
 (0)