File tree Expand file tree Collapse file tree
main/java/datadog/trace/api
test/groovy/datadog/trace/api
products/feature-flagging/feature-flagging-agent
src/test/java/com/datadog/featureflag Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,7 +268,7 @@ dependencies {
268268 api(project(" :components:context" ))
269269 api(project(" :components:environment" ))
270270 api(project(" :components:json" ))
271- api (project(" :products:feature-flagging:feature-flagging-config" ))
271+ implementation (project(" :products:feature-flagging:feature-flagging-config" ))
272272 api(project(" :utils:config-utils" ))
273273 api(project(" :utils:time-utils" ))
274274
Original file line number Diff line number Diff line change @@ -3802,7 +3802,21 @@ private static String normalizeFeatureFlaggingConfigurationSource(final String s
38023802 return DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE ;
38033803 }
38043804 final String normalized = source .trim ().toLowerCase (Locale .ROOT );
3805- return normalized .isEmpty () ? DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE : normalized ;
3805+ if (normalized .isEmpty ()) {
3806+ return DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE ;
3807+ }
3808+ switch (normalized ) {
3809+ case "agentless" :
3810+ case "remote_config" :
3811+ case "offline" :
3812+ return normalized ;
3813+ default :
3814+ log .warn (
3815+ "Unsupported Feature Flagging configuration source: {}. Defaulting to {}" ,
3816+ source ,
3817+ DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE );
3818+ return DEFAULT_FEATURE_FLAGGING_CONFIGURATION_SOURCE ;
3819+ }
38063820 }
38073821
38083822 public boolean isBaggageExtract () {
Original file line number Diff line number Diff line change @@ -3517,6 +3517,7 @@ class ConfigTest extends DDSpecification {
35173517 " " | " agentless"
35183518 " " | " agentless"
35193519 " ReMoTe_ConFiG " | " remote_config"
3520+ " not- a- real- source" | " agentless"
35203521 }
35213522
35223523 def " agentless feature flag timing falls back for non- positive values" () {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ dependencies {
2020
2121 testImplementation(libs.bundles.junit5)
2222 testImplementation(libs.bundles.mockito)
23+ testImplementation(project(" :products:feature-flagging:feature-flagging-config" ))
2324 testImplementation(project(" :utils:test-utils" ))
2425 testRuntimeOnly(project(" :dd-trace-core" ))
2526}
Original file line number Diff line number Diff line change @@ -97,12 +97,23 @@ void explicitRemoteConfigUsesRemoteConfigService() {
9797
9898 @ Test
9999 @ WithConfig (key = FEATURE_FLAGS_CONFIGURATION_SOURCE , value = "invalid" )
100- void invalidConfigurationSourceFailsBeforeStartingNetworkSource () {
100+ void invalidConfigurationSourceUsesAgentlessDefault () {
101+ assertInstanceOf (
102+ AgentlessConfigurationSource .class ,
103+ FeatureFlaggingSystem .createConfigurationSourceService (
104+ sharedCommunicationObjects (), Config .get ()));
105+ }
106+
107+ @ Test
108+ void rejectsUnsupportedNormalizedConfigurationSource () {
109+ Config config = mock (Config .class );
110+ when (config .getFeatureFlaggingConfigurationSource ()).thenReturn ("invalid" );
111+
101112 assertThrows (
102113 IllegalArgumentException .class ,
103114 () ->
104115 FeatureFlaggingSystem .createConfigurationSourceService (
105- sharedCommunicationObjects (), Config . get () ));
116+ sharedCommunicationObjects (), config ));
106117 }
107118
108119 @ Test
You can’t perform that action at this time.
0 commit comments