Skip to content

Conversation

@Adobels
Copy link

@Adobels Adobels commented Dec 16, 2025

Motivation

Add support for 1, 0, and YES, NO boolean strings in EnvironmentVariablesProvider. Support for YES and NO boolean strings was not discussed in the original issue. From personal experience, I found it interesting to include it. If rejected, I will remove it. I tried to remain consitent with the existing decoders and the way they are used by the provider.

Closes #110

Modifications

The EnvironmentVariablesProvider's bool decoder is configurable and can be initialized with support for true/false, 1/0, yes/no, or any combination of them.

Result

Usage of EnvironmentVariablesProvider has not changed, but by default all pairs of boolean strings are accepted when retrieving values as Bool or BoolArray. Client code can configure the provider to use a bool decoder with support only for true/false strings.

If it is more important to keep the behavior as it was, meaning default support for true/false only in the provider, then I will modify the default set for the EnvironmentVariablesProvider BoolDecoder.

Test Plan

The decoder is tested with dedicated tests, and additional tests for receiving a value from a provider were added to test the integration of BoolDecoder with EnvironmentVariablesProvider.

Code is commented, and tests are green locally.

@Adobels Adobels marked this pull request as draft December 16, 2025 16:07
@Adobels Adobels marked this pull request as ready for review December 16, 2025 16:14
@czechboy0
Copy link
Contributor

czechboy0 commented Dec 16, 2025

Thank you @Adobels! A few pieces of feedback:

  • I appreciate you future-proofing this by making the string-to-bool decoder customizable, but let's not add that to the API yet. We can always add it in the future, but for now please make it an implementation detail and hardcode to the logic you chose.
  • I do like supporting YES/NO as well, I don't expect this to cause confusion and many other systems support this too.
  • In the tests, please don't expand the default set of values, create a dedicated test that exhaustively tests these various Boolean variants.

And just FYI, I'm going on vacation so my responses will be slower until early January.

@Adobels Adobels marked this pull request as draft December 16, 2025 18:57
@Adobels Adobels marked this pull request as draft December 16, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parse 1 as a true Boolean in EnvironmentVariablesProvider

2 participants