Skip to content

Conversation

@simonsabin
Copy link
Collaborator

… it uses the environment replacement and looks for a true false 1 or 0.

Why make this change?

Fixes #3053

Boolean values can't be set using environment variables. This allows that

What is this change?

Using custom JsonConverter for bools that if a string is detected it uses the string serialiser that uses the environment replacement rules.

How was this tested?

  • Integration Tests
  • Unit Tests

… then it uses the environment replacement and looks for a true false 1 or 0.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes issue #3053 by enabling boolean configuration values to be set using environment variables. Previously, boolean values could not use environment variable substitution like string values could.

Changes:

  • Added a custom BoolJsonConverter that handles boolean deserialization from both native JSON boolean tokens and string tokens (which enables environment variable substitution)
  • Registered the new converter in the JSON serialization pipeline
  • Added unit tests to validate boolean values can be set through environment variables

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
src/Config/Converters/BooleanJsonConverterFactory.cs New custom JSON converter that deserializes boolean values from both JSON booleans and strings, enabling environment variable substitution
src/Config/RuntimeConfigLoader.cs Registers the BoolJsonConverter in the serialization options
src/Service.Tests/UnitTests/RuntimeConfigLoaderJsonDeserializerTests.cs Adds test coverage for boolean environment variable replacement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

simonsabin and others added 4 commits January 13, 2026 23:12
…rTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…rTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
""runtime"": {
""telemetry"": {
""application-insights"": {
""enabled"": " + configValue + @",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a test for the configValue itself be in double quotes? So,

"enabled" : "true" or
"enabled" : "@env('application_insights_enabled')"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the current test is not testing the scenario when configValue is hardcoded to true because this code will translate to "enabled": true,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putting a load more tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a whole set of extra tests to handle string and non string booleans

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test now check for true, false, 0, 1 natively, hardcoded within a string, or from an environment replacement.
Assuming keyvault replacements would "just work"

Copy link
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional testing for double quoted value boolean value to test the string deserialization.

@simonsabin
Copy link
Collaborator Author

Additional testing for double quoted value boolean value to test the string deserialization.

I think this is now catered for it you mean where the json is the following.

{
 .... 
  "enabled": "true"
  ...
}

and also

{
 .... 
   "enabled": true
  ...
}

@simonsabin simonsabin requested a review from Aniruddh25 January 14, 2026 01:10
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.

[Bug]: Application Insights can't be disabled by environment variables

2 participants