GitHub Actions workflow_dispatch Inputs Empty or Wrong Type
A manually dispatched workflow reads its inputs as empty or behaves oddly because they are referenced from the wrong context, a boolean input is actually a string, or the input was never declared.
What this error means
A workflow_dispatch run reads an input as an empty string, or a boolean input always evaluates truthy because it is compared as a string rather than a boolean.
# boolean input compared as a string is always truthy
if: github.event.inputs.deploy == 'true' # works
if: github.event.inputs.deploy # 'false' string is still truthyCommon causes
Input not declared or wrong context
Inputs must be declared under on.workflow_dispatch.inputs. Reading an undeclared input, or using the wrong context, yields an empty value.
Boolean inputs are strings in some contexts
A workflow_dispatch boolean input is exposed as the string "true"/"false" via github.event.inputs, so a bare truthiness check on the string is always true.
How to fix it
Declare inputs and use the inputs context
Declare each input with a type, then read it via the inputs context, comparing booleans explicitly.
on:
workflow_dispatch:
inputs:
deploy:
type: boolean
default: false
jobs:
go:
if: ${{ inputs.deploy == true }}
runs-on: ubuntu-latest
steps: [{ run: ./deploy.sh }]Compare string inputs against literals
- For github.event.inputs.<name>, compare against the string "true" rather than relying on truthiness.
- Prefer the typed inputs context (inputs.<name>) where available.
- Set default: values so optional inputs are never empty.
How to prevent it
- Declare every workflow_dispatch input with a type and default.
- Compare boolean inputs explicitly instead of bare truthiness.
- Prefer the inputs context over github.event.inputs.