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>
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
@JerryNixon
Copy link
Contributor

I am not sure this resolves JSON Schema constraints/editing errors, does it?

simonsabin

This comment was marked as outdated.

@simonsabin
Copy link
Collaborator Author

I am not sure this resolves JSON Schema constraints/editing errors, does it?

@JerryNixon It doesn't but I've just pushed change to the schema that would.

If thats an acceptable approach I can apply to other booleans.

Interestinlythere does seem to be a mix of json schema validation jsonconverter validation. The jsonconverter stuff looks overly complicated. for some simple serialisation.

@simonsabin
Copy link
Collaborator Author

Added tests to validate the schema approach. for key enabled flags.

@Aniruddh25
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@simonsabin
Copy link
Collaborator Author

forgot formatting, try again

@souvikghosh04 souvikghosh04 self-assigned this Jan 15, 2026
simonsabin and others added 3 commits January 15, 2026 18:00
Co-authored-by: Jerry Nixon <1749983+JerryNixon@users.noreply.github.com>
Co-authored-by: Jerry Nixon <1749983+JerryNixon@users.noreply.github.com>
Co-authored-by: Jerry Nixon <1749983+JerryNixon@users.noreply.github.com>
@JerryNixon
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@Aniruddh25
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

{
"type": [ "boolean", "string" ],
"pattern": "^(true|false|1|0|@env\\('.*'\\)|@akv\\('.*'\\))$"
"pattern": "^(?:true|false|1|0|@.{3}\\('.*'\\))$"
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldnt doing .{3} allow any pattern other than env or akv?

If yes, I think we should retain the previous pattern.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was @JerryNixon 's suggestion. Assume it was a bit of forward planning.

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.

Looks good, except for the pattern match for @env/@akv.

@simonsabin
Copy link
Collaborator Author

Looks good, except for the pattern match for @env/@akv.

Can you discuss this with @JerryNixon and decide

@simonsabin
Copy link
Collaborator Author

Integration tests aren't passing, is that an issue?

@Aniruddh25
Copy link
Collaborator

Integration tests aren't passing, is that an issue?

that's not. rerunning should fix it.

@Aniruddh25
Copy link
Collaborator

Looks good, except for the pattern match for @env/@akv.

Can you discuss this with @JerryNixon and decide

checked with Jerry. your previous pattern is what we both recommend.

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

4 participants