You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have defined a [Parameter] value of type bool? to indicate an optional build property.
It has null as default value which works as expected when testing the behavior locally.
However, I have also enabled Team City integration and as such, an environment variable named according to my parameter is automatically associated with my target's build configuration. Team City sets the associated environment variable to an empty string via the generated Kotlin script.
When my nuke target is run on CI, the bool? parameter is automatically parsed from this empty environment variable and somewhat surprisingly ends up being false rather than null.
This behavior seems to have changed and was originally working as I would expect. My issue seems to have been introduced when updating Nuke from v8.0.0 to v8.1.2 and it's like this up to the current version 9.0.3.
Reproduction Steps
Define a [Parameter] attributed field readonly bool? TestBoolean;
Set the environment variable TestBoolean to an empty string and run nuke with any target.
Inside the target's Executes logic, refer to TestBoolean.
Expected Behavior
The value of the TestBoolean field is null.
Actual Behavior
The value of the TestBoolean field is false.
Regression?
No response
Known Workarounds
One can of course define the parameter field as string? and try-parse the value manually.
Could you help with a pull-request?
No
The text was updated successfully, but these errors were encountered:
@paralaxsd The current implementation only returns null on bool? parameters if the parameter neither exists on command line nor in environment variables.
If it DOES exists it must be either true or false.
Even when "it used to work", I think it is risky to assume anything based on a null-value boolean, I would go for a different solution.
The current implementation only returns null on bool? parameters if the parameter neither exists on command line nor in environment variables.
Exactly. And since Team City exposes the env var unconditionally, Nuke picks up the empty bool? parameter as false.
I think this interplay is somewhat unexpected as it breaks nullable value type parameters in conjunction with Team City Kotlin script generation.
Perhaps interpreting the empty string as null for nullable value types could be a viable way to support this scenario? Just food for thought.
Usage Information
9.0.3 / net9.0
Description
I have defined a
[Parameter]
value of typebool?
to indicate an optional build property.It has
null
as default value which works as expected when testing the behavior locally.However, I have also enabled Team City integration and as such, an environment variable named according to my parameter is automatically associated with my target's build configuration. Team City sets the associated environment variable to an empty string via the generated Kotlin script.
When my nuke target is run on CI, the bool? parameter is automatically parsed from this empty environment variable and somewhat surprisingly ends up being
false
rather thannull
.This behavior seems to have changed and was originally working as I would expect. My issue seems to have been introduced when updating Nuke from v8.0.0 to v8.1.2 and it's like this up to the current version 9.0.3.
Reproduction Steps
[Parameter]
attributed fieldreadonly bool? TestBoolean;
TestBoolean
to an empty string and run nuke with any target.Executes
logic, refer toTestBoolean
.Expected Behavior
The value of the
TestBoolean
field isnull
.Actual Behavior
The value of the
TestBoolean
field isfalse
.Regression?
No response
Known Workarounds
One can of course define the parameter field as string? and try-parse the value manually.
Could you help with a pull-request?
No
The text was updated successfully, but these errors were encountered: