Skip to content

Commit f411f22

Browse files
PerfectSlayerclaude
andcommitted
refactor(ffe): Parse the configuration source like the agent
Parse the Feature Flags configuration source like the agent enum config parsing: case insensitive, with no trimming of surrounding spaces, so the SDK and the agent keep resolving the same configuration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 733666b commit f411f22

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

‎dd-openfeature/src/main/java/com/datadog/openfeature/internal/config/Settings.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public String configurationSource() {
9090
@Nullable
9191
private String resolveSource() {
9292
final Boolean enabled = getBoolean(FEATURE_FLAGS_ENABLED);
93-
final String source = normalize(get(FEATURE_FLAGS_CONFIGURATION_SOURCE));
93+
final String source = normalizeSource(get(FEATURE_FLAGS_CONFIGURATION_SOURCE));
9494
if (Boolean.FALSE.equals(enabled)) {
9595
return null;
9696
}
@@ -238,6 +238,15 @@ private static String normalize(@Nullable final String value) {
238238
return trimmed == null ? null : trimmed.toLowerCase(Locale.ROOT);
239239
}
240240

241+
/**
242+
* Normalizes the configuration source like the agent enum parsing: case insensitive, with no
243+
* trimming of surrounding spaces.
244+
*/
245+
@Nullable
246+
private static String normalizeSource(@Nullable final String value) {
247+
return nonBlank(value) == null ? null : value.replace('/', '_').toLowerCase(Locale.ROOT);
248+
}
249+
241250
@Nullable
242251
private static String nonBlank(@Nullable final String value) {
243252
if (value == null) {

‎dd-openfeature/src/test/java/com/datadog/openfeature/internal/config/SettingsTest.java‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@ void mapsKeysToEnvironmentVariables(final String key, final String variable) {
4444
}
4545

4646
@TableTest({
47-
"scenario | enabled | source | legacy | resolved ",
48-
"default | | | | 'agentless' ",
49-
"explicit agentless | | 'agentless' | | 'agentless' ",
50-
"explicit remote config | | 'remote_config' | | 'remote_config'",
51-
"normalized source | | ' Remote_Config ' | | 'remote_config'",
52-
"unsupported source | | 'offline' | | ",
53-
"blank source | | ' ' | | 'agentless' ",
54-
"disabled wins over source | 'false' | 'remote_config' | | ",
55-
"enabled keeps default | 'true' | | | 'agentless' ",
56-
"legacy enabled selects rc | | | 'true' | 'remote_config'",
57-
"legacy disabled disables | | | 'false' | ",
58-
"explicit source wins over legacy | | 'agentless' | 'false' | 'agentless' ",
59-
"invalid enabled reads as false | 'maybe' | | | ",
60-
"numeric disabled | '0' | | | "
47+
"scenario | enabled | source | legacy | resolved ",
48+
"default | | | | 'agentless' ",
49+
"explicit agentless | | 'agentless' | | 'agentless' ",
50+
"explicit remote config | | 'remote_config' | | 'remote_config'",
51+
"case insensitive source | | 'Remote_Config' | | 'remote_config'",
52+
"padded source | | ' agentless ' | | ",
53+
"unsupported source | | 'offline' | | ",
54+
"blank source | | ' ' | | 'agentless' ",
55+
"disabled wins over source | 'false' | 'remote_config' | | ",
56+
"enabled keeps default | 'true' | | | 'agentless' ",
57+
"legacy enabled selects rc | | | 'true' | 'remote_config'",
58+
"legacy disabled disables | | | 'false' | ",
59+
"explicit source wins over legacy | | 'agentless' | 'false' | 'agentless' ",
60+
"invalid enabled reads as false | 'maybe' | | | ",
61+
"numeric disabled | '0' | | | "
6162
})
6263
void resolvesConfigurationSource(
6364
final String enabled, final String source, final String legacy, final String resolved) {

0 commit comments

Comments
 (0)