@@ -159,7 +159,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
159
159
const loadedSettings : ConfigurationSetting [ ] = [ ] ;
160
160
161
161
// validate selectors
162
- const selectors = getValidSelectors ( this . #options?. selectors ) ;
162
+ const selectors = getValidKeyValueSelectors ( this . #options?. selectors ) ;
163
163
164
164
for ( const selector of selectors ) {
165
165
const listOptions : ListConfigurationSettingsOptions = {
@@ -240,7 +240,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
240
240
241
241
async #loadFeatureFlags( ) {
242
242
const featureFlags : FeatureFlagValue [ ] = [ ] ;
243
- const featureFlagSelectors = getValidSelectors ( this . #options?. featureFlagOptions ?. selectors ) ;
243
+ const featureFlagSelectors = getValidFeatureFlagSelectors ( this . #options?. featureFlagOptions ?. selectors ) ;
244
244
for ( const selector of featureFlagSelectors ) {
245
245
const listOptions : ListConfigurationSettingsOptions = {
246
246
keyFilter : `${ featureFlagPrefix } ${ selector . keyFilter } ` ,
@@ -465,12 +465,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
465
465
}
466
466
}
467
467
468
- function getValidSelectors ( selectors ?: SettingSelector [ ] ) {
469
- if ( ! selectors || selectors . length === 0 ) {
470
- // Default selector: key: *, label: \0
471
- return [ { keyFilter : KeyFilter . Any , labelFilter : LabelFilter . Null } ] ;
472
- }
473
-
468
+ function validateSelectors ( selectors : SettingSelector [ ] ) {
474
469
// below code deduplicates selectors by keyFilter and labelFilter, the latter selector wins
475
470
const uniqueSelectors : SettingSelector [ ] = [ ] ;
476
471
for ( const selector of selectors ) {
@@ -495,3 +490,20 @@ function getValidSelectors(selectors?: SettingSelector[]) {
495
490
return selector ;
496
491
} ) ;
497
492
}
493
+
494
+ function getValidKeyValueSelectors ( selectors ?: SettingSelector [ ] ) {
495
+ if ( ! selectors || selectors . length === 0 ) {
496
+ // Default selector: key: *, label: \0
497
+ return [ { keyFilter : KeyFilter . Any , labelFilter : LabelFilter . Null } ] ;
498
+ }
499
+ return validateSelectors ( selectors ) ;
500
+ }
501
+
502
+ function getValidFeatureFlagSelectors ( selectors ?: SettingSelector [ ] ) {
503
+ if ( ! selectors || selectors . length === 0 ) {
504
+ // selectors must be explicitly provided.
505
+ throw new Error ( "Feature flag selectors must be provided." ) ;
506
+ } else {
507
+ return validateSelectors ( selectors ) ;
508
+ }
509
+ }
0 commit comments