From 13ed8cbf31816cbf8df1e36c650885ae38fb35f6 Mon Sep 17 00:00:00 2001 From: buildingisfun23 Date: Sat, 11 Apr 2026 13:41:29 -0700 Subject: [PATCH] feat: add error-level log output on invalid env var parsing When flagd options in environment variables cannot be parsed (e.g., non-numeric value for an integer option), the code silently falls back to default values. This adds ERROR-level log messages at each fallback point so users are informed about misconfigurations. Closes #1673 --- .../contrib/providers/flagd/Config.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/Config.java b/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/Config.java index f88cfdd13..618d006f7 100644 --- a/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/Config.java +++ b/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/Config.java @@ -85,6 +85,11 @@ static int fallBackToEnvOrDefault(String key, int defaultValue) { try { return System.getenv(key) != null ? Integer.parseInt(System.getenv(key)) : defaultValue; } catch (Exception e) { + log.error( + "Failed to parse env variable '{}' with value '{}' as int, using default: {}", + key, + System.getenv(key), + defaultValue); return defaultValue; } } @@ -93,6 +98,11 @@ static long fallBackToEnvOrDefault(String key, long defaultValue) { try { return System.getenv(key) != null ? Long.parseLong(System.getenv(key)) : defaultValue; } catch (Exception e) { + log.error( + "Failed to parse env variable '{}' with value '{}' as long, using default: {}", + key, + System.getenv(key), + defaultValue); return defaultValue; } } @@ -105,6 +115,11 @@ static List fallBackToEnvOrDefaultList(String key, List defaultV .collect(Collectors.toList()) : defaultValue; } catch (Exception e) { + log.error( + "Failed to parse env variable '{}' with value '{}' as list, using default: {}", + key, + System.getenv(key), + defaultValue); return defaultValue; } }