We propose standardizing configuration type conversion behavior across all data types in the next major release, specifically changing how invalid boolean values are handled to match the behavior of other numeric types.
Currently, our configuration system exhibits inconsistent behavior when handling invalid values:
Numeric Types (Integer, Float, Double, Long):
// Environment: DD_SOME_INT=invalid_number
int value = configProvider.getInteger("some.int", 42);
// Result: 42 (default value) ✅Boolean Type:
// Environment: DD_SOME_BOOL=invalid_boolean
boolean value = configProvider.getBoolean("some.bool", true);
// Result: false (hardcoded fallback) ❌- Unexpected Behavior: Users expect invalid values to fall back to their explicitly provided defaults
- Silent Failures: Invalid boolean configurations silently become
false, making debugging difficult - API Inconsistency: Different data types behave differently for the same logical error condition
- Code Complexity: Requires custom exception handling and special-case logic
To maintain backward compatibility while fixing our test suite, we implemented a temporary solution:
// ConfigConverter.java
static class InvalidBooleanValueException extends IllegalArgumentException {
// Custom exception for backward compatibility
}
public static Boolean booleanValueOf(String value) {
// ... validation logic ...
throw new InvalidBooleanValueException("Invalid boolean value: " + value);
}
// ConfigProvider.java
catch (ConfigConverter.InvalidBooleanValueException ex) {
// Special case: return false instead of default for backward compatibility
return (T) Boolean.FALSE;
}This approach works but adds complexity and maintains the inconsistent behavior.
- Remove Custom Boolean Logic: Eliminate
InvalidBooleanValueExceptionand special handling - Consistent Exception Handling: All invalid type conversions throw
IllegalArgumentException - Consistent Fallback Behavior: All types fall back to user-provided defaults
// All types will behave consistently:
int intValue = configProvider.getInteger("key", 42); // invalid → 42
boolean boolValue = configProvider.getBoolean("key", true); // invalid → true
float floatValue = configProvider.getFloat("key", 3.14f); // invalid → 3.14f- Remove
InvalidBooleanValueExceptionclass - Update
ConfigConverter.booleanValueOf()to throwIllegalArgumentException - Remove special boolean handling from
ConfigProvider.get() - Update documentation and migration guide
- Release notes highlighting the breaking change
- Update configuration documentation with examples
- Provide migration guidance for affected users
- Users who rely on invalid boolean values defaulting to
false - Applications that depend on the current behavior for error handling
Users can adapt by:
- Fixing Invalid Configurations: Update configurations to use valid boolean values
- Adjusting Defaults: If they want
falseas fallback, explicitly setfalseas the default - Adding Validation: Implement application-level validation if needed
// Before (relied on invalid → false)
boolean feature = configProvider.getBoolean("feature.enabled", true);
// After (explicit about wanting false for invalid values)
boolean feature = configProvider.getBoolean("feature.enabled", false);- Predictable Behavior: Invalid values consistently fall back to provided defaults
- Better Debugging: Clear error signals when configurations are invalid
- Explicit Intent: Default values clearly express intended fallback behavior
- Simplified Codebase: Remove custom exception types and special-case logic
- Consistent Testing: All type conversions can be tested with the same patterns
- Reduced Complexity: Fewer edge cases and branches to maintain
We recommend implementing this change in the next major release (e.g., v2.0) because:
- Improves User Experience: More predictable and debuggable configuration behavior
- Reduces Technical Debt: Eliminates custom workarounds and special cases
- Aligns with Principle of Least Surprise: Consistent behavior across all data types
- Proper Breaking Change Window: Major release is the appropriate time for behavior changes
- Do we agree this inconsistency is worth fixing with a breaking change?
- Should we provide any additional migration tooling or validation?
- Are there other configuration behaviors we should standardize at the same time?
- What timeline works best for communicating this change to users?
Next Steps: If approved, we'll create implementation issues and begin updating documentation for the next major release cycle.