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 guess this is a github service bug, sadly broken by design :(.
the value of the workflow_dispatch payload is 'false', but both of us are expecting a boolean false and not a string.
Why does this happen? 'false' is a non empty string, which is truthy.
However this might align to previous workflow_dispatch behavior, all inputs are strings like before.
This is super inconsistent with reusable workflows workflow_call ( beta ), because type: boolean does mean boolean and not a string like in workflow_dispatch.
Reacted by Αlexandru-Paul Copil, Jan Steinke, Albert Mañosa, Alex Vincent, Michael Rehkemper, John Mitchell, Sam, Victor, Rainer Scholz, Alex Rashed and 11 more
Reacted by Flash Sheridan, Alex and arthury-lettuce
I have run into this issue as well, it is tricky to identify and debug. I have just been ensuring I always cast potential boolean values to a string, and always match on the string value.
Reacted by Αlexandru-Paul Copil, Isa Farnik, leonk-sportsbet, Farid Sheikh, Rainer Scholz, Isaac Ortega, keivin, Alexander Malitsky, Robbie Cargill, Kyler Middleton and 4 more
Seems like input field type in workflow is only for GitHub to know what UI controls should it use and all inputs are strings... So it seems we should check it like if: ${{ inputs.x == 'true' }}
Reacted by Frans Flippo, Jon Lauridsen, Max Ustinov, Marko Pacak, Tomasz Kalkosiński, Tiago Guimaraes, [DevOps] Lucas Pierru, Jérémy Cotineau, Maxim Surkov and Anton
And then match on outputs.foo == 'true' instead, which works every time.
Reacted by Ilham Adi Pratama, berlin4apk, Chris Natale, Erik Bjäreholt, Josh-Osmanski, John Mitchell, mizinovv, David Stück, Jacob Asper, Dixon Sean Low Yan Feng and 9 more
@solarmosaic-kflorence Yeah they should clearly document this behavior it can be really confusing. Maybe there is some documentation mentioning this but I did not stumbled upon this for a year now when working with GitHub...
Reacted by Thomas Evans, Albert Mañosa, mzlatev, mizinovv, Chad Tolkien, [DevOps] Lucas Pierru and Michał Zawadzki
This is actually really bad because there's no way to write a workflow such that if this bug is fixed your workflow continues to operate as normal. I can't figure out an expression that returns true only if a variable is not the string 'false' and also not the boolean false, because any boolean test I do will be coercing the argument and returning true absent a literal empty string argument.
Reacted by Chris Natale, Scott Long, Isaac Ortega, Christopher Virtucio and Felix Fontein
I can't figure out an expression that returns true only if a variable is not the string 'false' and also not the boolean false
Have you tried ${{fromJSON(github.event.inputs.foo)}} or ${{fromJSON(github.event.inputs.foo)}}? I'm not shure if this 100% does what you expect..
The trick fromJSON expects a string value, if it receives a boolean it is converted to string false => 'false', true => 'true'. Then fromJSON translates the boolean string back to a real boolean.
You can also cast the input to a string with ${{format('{0}', github.event.inputs.foo)}} then you always have the boolean as string. Then you could use ${{format('{0}', github.event.inputs.foo) != 'false'}}, this might even work with malformed inputs which aren't valid json.
This is actually really bad because there's no way to write a workflow such that if this bug is fixed your workflow continues to operate as normal. I can't figure out an expression that returns true only if a variable is not the string 'false' and also not the boolean false, because any boolean test I do will be coercing the argument and returning true absent a literal empty string argument.
@scottmmjackson Seems like something like this could work I think (still seems quite ugly):
We will track a different issue as feature enhancement separately :)
Hi @ajaykn, which issue will be used to track this behavior? #2238? It looks to be this same issue, but I'm not sure. Would you clarify? I'd like to make sure I'm subscribed to the right ticket and also able to escalate this to our GH liason.
name: Build Single Image
on:
workflow_call:
inputs:
build:
description: 'Flag whether to build the Image'
required: true
type: boolean
image:
description: 'Image to build: api or ui'
required: true
type: string
tag:
description: 'Image tag'
required: true
type: string
jobs:
build-and-push:
if: inputs.build
...
Seems the matrix involvement undermines all the above e.g. reverting/coercing all things to strings; I was getting two annotations with the same report:
The template is not valid. (Line: 187, Col: 14): Unexpected value 'true'
Note no mention of the expected boolean type.
Also note the annoying hack to workaround the matrix context not being available for use in jobs.<job_id>.if
The fromJSON trick mentioned above (credit to the appropriate community member) did the trick... it only took 50 odd failed runs of debugging to get here.
Reacted by Kyle King, Alexander Malitsky and Piotr
To convert the "boolean" input of a workflow_dispatch to be consumable by the boolean input of a workflow_call I used the following logic: ${{ inputs.my-bool == true || inputs.my-bool == 'true' }}
This will accept a boolean true or the string "true" as input to make it true, anything else is false. EDIT: Fixed the error as pointed out by @piotrekkr in the comment below. Thanks! It should have been a || and not &&, and also inputs instead of input. My suggestion above is now correct 🎉 .
To convert the "boolean" input of a workflow_dispatch to be consumable by the boolean input of a workflow_call I used the following logic: ${{ input.my-bool == true && input.my-bool == 'true' }} This will accept a boolean true or the string "true" as input to make it true, anything else is false.
@markwhitfeld You mean ${{ input.my-bool == true || input.my-bool == 'true' }}? Otherwise a variable cannot be bool and string at same time so at least one of conditions will always fail and whole expression will be false.
Inputs are still strings (when using gh workflow run, but the "boolean" input behaves like an enum with "true" and "false" being the only two options that are later cast to a proper boolean. I imagine numbers could be working same way, but didn't validate that.
I'm confused about the recent activity referencing this issue. Did the problem reappear at some point?
Inputs are still strings (when using gh workflow run, but the "boolean" input behaves like an enum with "true" and "false" being the only two options that are later cast to a proper boolean. I imagine numbers could be working same way, but didn't validate that.
I'm confused about the recent activity referencing this issue. Did the problem reappear at some point?
@Kristonitas I think those issues you added in screenshot were about output params and not inputs. Maybe outputs were mixed with inputs by some people and those were incorrectly linked to this issue.
P. S. The arguments passed between workflows are still serialised as strings afaik (hence you can't use json booleans when using the json input flag echo '{"passed_true": true, "passed_false": false}' | gh workflow run test.yml --json would fail). So seeing strings as output "booleans" could still make sense.
Activity
GH Actions: Fix a couple of issues
ChristopherHX commentedon Nov 15, 2021
I guess this is a github service bug, sadly broken by design :(.
the value of the workflow_dispatch payload is
'false', but both of us are expecting a booleanfalseand not a string.Why does this happen?
'false'is a non empty string, which is truthy.However this might align to previous
workflow_dispatchbehavior, all inputs are strings like before.This is super inconsistent with reusable workflows
workflow_call( beta ), becausetype: booleandoes mean boolean and not a string like inworkflow_dispatch.[-]Boolean inputs do not work in `if:`[/-][+]Boolean inputs are not actually booleans[/+]solarmosaic-kflorence commentedon Dec 10, 2021
I have run into this issue as well, it is tricky to identify and debug. I have just been ensuring I always cast potential boolean values to a string, and always match on the string value.
TingluoHuang commentedon Dec 13, 2021
@ericsciple do you have any thoughts on this?
piotrekkr commentedon Dec 15, 2021
Seems like input field type in workflow is only for GitHub to know what UI controls should it use and all inputs are strings... So it seems we should check it like
if: ${{ inputs.x == 'true' }}solarmosaic-kflorence commentedon Dec 15, 2021
@piotrekkr it is the same for outputs, for example:
The
foooutput would be type boolean, likefalse, but matching onoutputs.foo == falsedoesn't seem to work. So instead I do:And then match on
outputs.foo == 'true'instead, which works every time.piotrekkr commentedon Dec 16, 2021
@solarmosaic-kflorence Yeah they should clearly document this behavior it can be really confusing. Maybe there is some documentation mentioning this but I did not stumbled upon this for a year now when working with GitHub...
scottmmjackson commentedon Dec 16, 2021
This is actually really bad because there's no way to write a workflow such that if this bug is fixed your workflow continues to operate as normal. I can't figure out an expression that returns true only if a variable is not the string
'false'and also not the booleanfalse, because any boolean test I do will be coercing the argument and returningtrueabsent a literal empty string argument.ChristopherHX commentedon Dec 16, 2021
Have you tried
${{fromJSON(github.event.inputs.foo)}}or${{fromJSON(github.event.inputs.foo)}}? I'm not shure if this 100% does what you expect..The trick
fromJSONexpects a string value, if it receives a boolean it is converted to stringfalse=>'false',true=>'true'. ThenfromJSONtranslates the boolean string back to a real boolean.You can also cast the input to a string with
${{format('{0}', github.event.inputs.foo)}}then you always have the boolean as string. Then you could use${{format('{0}', github.event.inputs.foo) != 'false'}}, this might even work with malformed inputs which aren't valid json.piotrekkr commentedon Dec 17, 2021
@scottmmjackson Seems like something like this could work I think (still seems quite ugly):
should give
//EDIT
Ok seems like it may not work with empty strings because javascript...
FIX booelan issue on manual tests
FIX boolean issue on manual tests
kagahd commentedon Feb 7, 2022
I have a similar case by reusing workflows where I want let the caller of the reused workflow decide about
continue-on-errorI found the following workaround, where the input variable type is
stringinstead ofbooleanwhich is casted tobooleanbyfromJSONlater on:105 remaining items
ACS-4500 Fix skip tests in reusable workflow
Fixed `if` expressions to be evaluated correctly
ci(release): handle workflow dispatch input boolean actually being a …
dekimsey commentedon Mar 24, 2023
Hi @ajaykn, which issue will be used to track this behavior? #2238? It looks to be this same issue, but I'm not sure. Would you clarify? I'd like to make sure I'm subscribed to the right ticket and also able to escalate this to our GH liason.
Thank you!
Fix test for boolean input
DarrenBishop commentedon Sep 6, 2023
Having similar issues, variation on a theme:
...and the called workflow
Seems the
matrixinvolvement undermines all the above e.g. reverting/coercing all things to strings; I was getting two annotations with the same report:Note no mention of the expected
booleantype.Also note the annoying hack to workaround the
matrixcontext not being available for use injobs.<job_id>.ifThe
fromJSONtrick mentioned above (credit to the appropriate community member) did the trick... it only took 50 odd failed runs of debugging to get here.markwhitfeld commentedon Dec 14, 2023
To convert the "boolean" input of a
workflow_dispatchto be consumable by the boolean input of aworkflow_callI used the following logic:${{ inputs.my-bool == true || inputs.my-bool == 'true' }}This will accept a boolean
trueor the string"true"as input to make it true, anything else is false.EDIT: Fixed the error as pointed out by @piotrekkr in the comment below. Thanks! It should have been a
||and not&&, and alsoinputsinstead ofinput. My suggestion above is now correct 🎉 .piotrekkr commentedon Dec 14, 2023
@markwhitfeld You mean
${{ input.my-bool == true || input.my-bool == 'true' }}? Otherwise a variable cannot beboolandstringat same time so at least one of conditions will always fail and whole expression will befalse.//EDIT
I think you should also use
inputsand notinputKristonitas commentedon May 29, 2024
This isn't happening any more since some time 2023: github/docs@e7a6d02
Inputs are still strings (when using
gh workflow run, but the "boolean" input behaves like an enum with"true"and"false"being the only two options that are later cast to a proper boolean. I imagine numbers could be working same way, but didn't validate that.I'm confused about the recent activity referencing this issue. Did the problem reappear at some point?

chkp-sergeyl commentedon Jun 10, 2024
well, this is still not working as expected. putting if: ${{ inputs.SOME_BOOLEAN }} doesn't evaluate booleans.
piotrekkr commentedon Jun 10, 2024
@Kristonitas I think those issues you added in screenshot were about output params and not inputs. Maybe outputs were mixed with inputs by some people and those were incorrectly linked to this issue.
hassanalamibmx commentedon Jun 10, 2024
It's working great for me, can you provide an example?
Kristonitas commentedon Jun 10, 2024
@libermansa


I remade the test that was posted early in this issue, with results that we expect from bool inputs:
https://github.com/Kristonitas/ga-bool-input-test
The scenario that was reported in #1483 (comment) (and other similar tests) is not happening right now
@piotrekkr
Thanks for pointing that out
P. S. The arguments passed between workflows are still serialised as strings afaik (hence you can't use json booleans when using the json input flag
echo '{"passed_true": true, "passed_false": false}' | gh workflow run test.yml --jsonwould fail). So seeing strings as output "booleans" could still make sense.rainabba commentedon Jun 10, 2024
I found that I needed to use
fromJSON()(see: https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) around my "boolean" params to get them to behave as expected.sanjacob commentedon Aug 14, 2024
Still happens in env at least. I had to use
fromJSON