JSON Configuration Variables, unable to set null

Hi folks,

been using Octopus for quite a few years now, and recently run into an issue with variable substitution in JSON files. No matter what I try, I end up with an empty string in my JSON file, or “null”, instead of a proper null value.

e.g. My JSON file:

{
“oidc”: {
“authMaxAge”: null
}
}

Some Tenants need to have a timestamp string in here, such as “0.00:20:00.0000”, however others should have a null value.

I’ve tried the following:

  • Leaving the variable blank - results in “authMaxAge”: “”
  • Entering the value null in the variable - results in “authMaxAge”: “null”

Any idea what I’m doing wrong? I’m on version 3.16.1, and planning to upgrade at the end of this sprint. I’ve seen this topic: https://help.octopusdeploy.com/discussions/problems/47779-json-configuration-variables-feature-not-allowing-empty-strings-on-version-34 which sounds like what I’m after, but it doesn’t seem to work for me.

Thanks very much,

Paul Reynolds

Some additional information:

  • I’m deploying to Azure Web App
  • The variable I’m using will potentially be assigned from both a Variable Set and Tenant Project Variables

Hi, thanks for getting in touch.

I might need a little more info to reproduce your exact scenario. However, I can see that the tests for putting null in is still there and working. See here.

Note that there is the usual difference between a variable set to null and one containing the empty string.

Can you give me a little more info about what you are doing and how it’s set up, so I can reproduce my side.

Michael

Thanks Michael,

I’ve attached a screenshot of the variable I’m setting. I’ve tried this on the Project Variables section as well as the Variable Set section. The JSON file looks like this:

Before substitution
{
“oidc”: {
“authMaxAge”: null
}
}

After substitution
{
“oidc”: {
“authMaxAge”: “”
}
}

The default for this value is null, however I wish to configure certain Tenants to have null, and other Tenants to have a string value. I’m deploying to an Azure Web App and using the JSON Configuration Variables options (see 2nd Screenshot).

Thanks,

Paul

Hi,

Thanks for the screenshots, that helps in reproducing.

Starting fresh and creating a variable, but not entering any value is a null, and so gives “authMaxAge”: null. However, after a value is added, but then deleted, the variable value will be "", and so “authMaxAge”: "".

I’m guessing that at one stage your variable was given a value that was later deleted.

Using the UI, the only way to get back to null after it has had a value is to delete, save and then re-add the variable.

Michael

Hi Michael,

I’ve tried these steps and still no joy unfortunately. I’m going to see how things go once I’ve upgraded to the newest version of Octopus since I know you guys have made a bunch of improvements to the Variable Editing, and the UI in general.

Paul

Great, let me know if you still have any issues.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.