@@ -159,7 +159,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
159159 const loadedSettings : ConfigurationSetting [ ] = [ ] ;
160160
161161 // validate selectors
162- const selectors = getValidSelectors ( this . #options?. selectors ) ;
162+ const selectors = getValidKeyValueSelectors ( this . #options?. selectors ) ;
163163
164164 for ( const selector of selectors ) {
165165 const listOptions : ListConfigurationSettingsOptions = {
@@ -240,7 +240,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
240240
241241 async #loadFeatureFlags( ) {
242242 const featureFlags : FeatureFlagValue [ ] = [ ] ;
243- const featureFlagSelectors = getValidSelectors ( this . #options?. featureFlagOptions ?. selectors ) ;
243+ const featureFlagSelectors = getValidFeatureFlagSelectors ( this . #options?. featureFlagOptions ?. selectors ) ;
244244 for ( const selector of featureFlagSelectors ) {
245245 const listOptions : ListConfigurationSettingsOptions = {
246246 keyFilter : `${ featureFlagPrefix } ${ selector . keyFilter } ` ,
@@ -465,12 +465,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
465465 }
466466}
467467
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 [ ] ) {
474469 // below code deduplicates selectors by keyFilter and labelFilter, the latter selector wins
475470 const uniqueSelectors : SettingSelector [ ] = [ ] ;
476471 for ( const selector of selectors ) {
@@ -495,3 +490,20 @@ function getValidSelectors(selectors?: SettingSelector[]) {
495490 return selector ;
496491 } ) ;
497492}
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