@@ -106,9 +106,11 @@ async fn env_with_value(world: &mut ConfigWorld, env: String, value: String) {
106106
107107#[ when( expr = "a config was initialized" ) ]
108108async fn initialize_config ( world : & mut ConfigWorld ) {
109+ // Start with defaults (which reads from environment variables)
109110 let mut options = FlagdOptions :: default ( ) ;
111+ let mut resolver_explicitly_set = false ;
110112
111- // Handle resolver type first
113+ // Handle resolver type first - explicit options override env vars
112114 if let Some ( resolver) = world. option_values . get ( "resolver" ) {
113115 options. resolver_type = match resolver. to_uppercase ( ) . as_str ( ) {
114116 "RPC" => ResolverType :: Rpc ,
@@ -117,32 +119,27 @@ async fn initialize_config(world: &mut ConfigWorld) {
117119 "FILE" | "OFFLINE" => ResolverType :: File ,
118120 _ => ResolverType :: Rpc ,
119121 } ;
120- } else if let Ok ( resolver) = std:: env:: var ( "FLAGD_RESOLVER" ) {
121- options. resolver_type = match resolver. to_uppercase ( ) . as_str ( ) {
122- "RPC" => ResolverType :: Rpc ,
123- "REST" => ResolverType :: Rest ,
124- "IN-PROCESS" | "INPROCESS" => ResolverType :: InProcess ,
125- "FILE" | "OFFLINE" => ResolverType :: File ,
126- _ => ResolverType :: Rpc ,
122+ resolver_explicitly_set = true ;
123+ // Update port based on resolver type when explicitly set
124+ options. port = match options. resolver_type {
125+ ResolverType :: Rpc => 8013 ,
126+ ResolverType :: InProcess => 8015 ,
127+ _ => options. port ,
127128 } ;
128129 }
129130
130- // Set default port based on resolver type
131- options. port = match options. resolver_type {
132- ResolverType :: Rpc => 8013 ,
133- ResolverType :: InProcess => 8015 ,
134- _ => options. port ,
135- } ;
136-
137- // Handle source configuration after resolver type
131+ // Handle source configuration - may override resolver type for backwards compatibility
132+ // BUT only if resolver wasn't explicitly set to "rpc"
138133 if let Some ( source) = world. option_values . get ( "offlineFlagSourcePath" ) {
139134 options. source_configuration = Some ( source. clone ( ) ) ;
140- if options. resolver_type != ResolverType :: Rpc {
135+ // For backwards compatibility: if offline path is set, switch to File resolver
136+ // UNLESS resolver was explicitly set to "rpc" (in which case keep it as "rpc")
137+ if !resolver_explicitly_set || options. resolver_type != ResolverType :: Rpc {
141138 options. resolver_type = ResolverType :: File ;
142139 }
143140 }
144141
145- // Handle remaining explicit options
142+ // Handle remaining explicit options (these override env vars)
146143 if let Some ( host) = world. option_values . get ( "host" ) {
147144 options. host = host. clone ( ) ;
148145 }
@@ -217,6 +214,9 @@ async fn initialize_config(world: &mut ConfigWorld) {
217214 if let Some ( selector) = world. option_values . get ( "selector" ) {
218215 options. selector = Some ( selector. clone ( ) ) ;
219216 }
217+ if let Some ( provider_id) = world. option_values . get ( "providerId" ) {
218+ options. provider_id = Some ( provider_id. clone ( ) ) ;
219+ }
220220 if let Some ( max_size) = world
221221 . option_values
222222 . get ( "maxCacheSize" )
@@ -269,12 +269,26 @@ async fn check_option_value(
269269 "retryBackoffMaxMs" => Some ( world. options . retry_backoff_max_ms . to_string ( ) ) ,
270270 "retryGracePeriod" => Some ( world. options . retry_grace_period . to_string ( ) ) ,
271271 "selector" => world. options . selector . clone ( ) ,
272+ "providerId" => world. options . provider_id . clone ( ) ,
272273 "socketPath" => world. options . socket_path . clone ( ) ,
273274 "streamDeadlineMs" => Some ( world. options . stream_deadline_ms . to_string ( ) ) ,
274275 _ => None ,
275276 } ;
276277 let expected = convert_type ( & option_type, & value) ;
277- assert_eq ! ( actual, expected, "Option '{}' value mismatch" , option) ;
278+
279+ // For resolver type, do case-insensitive comparison since enum normalizes to lowercase
280+ let actual_normalized = if option == "resolver" {
281+ actual. as_ref ( ) . map ( |v| v. to_lowercase ( ) )
282+ } else {
283+ actual. clone ( )
284+ } ;
285+ let expected_normalized = if option == "resolver" {
286+ expected. as_ref ( ) . map ( |v| v. to_lowercase ( ) )
287+ } else {
288+ expected. clone ( )
289+ } ;
290+
291+ assert_eq ! ( actual_normalized, expected_normalized, "Option '{}' value mismatch" , option) ;
278292}
279293
280294#[ test( tokio:: test) ]
0 commit comments