Skip to Content
flowpact

FP105 · optional-input-no-default-in-condition

An optional input that is '' when omitted (no default, or `default: ''`) decides an `if:` by its truthiness.

CodeNameCategoryDefault severityReported by
FP105optional-input-no-default-in-conditionInputs🟡 warninglint, check, the action, the editor

Why it matters

When a caller omits an optional input that has no default, GitHub passes an empty string. A condition such as if: inputs.deploy then takes the "false" branch: the job or step is skipped and the run is still green, so nothing tells the caller that the value they left out turned it off.

How to fix

If it must run, make the input required: true or give it a non-empty default. If skipping is intended, say so where it is decided: inputs.x != '' (the same at run time, but explicit), or read the skipped step's outputs through a fallback (steps.token.outputs.token || github.token). default: '' is not a fix: it is what GitHub passes for an omitted input.

Example

inputs:
  environment: { type: string, required: false }
...
- if: inputs.environment
  run: ./deploy.sh "${{ inputs.environment }}"

Scope

Not reported: comparisons with a constant, contains()-style tests, fallbacks inside a comparison or function argument (startsWith(inputs.x || 'main', 'v')), conditions that are true when the input is '' (inputs.x || 'yes', !inputs.x), conditions with text around ${{ }} (always true; actionlint reports them), and a step whose results are only read through a fallback that is not empty when the step is skipped (steps.t.outputs.token || github.token, not || '' or the omitted input), in a condition that asks whether it ran (if: steps.t.outcome == 'success') or that is true when it was skipped, as a whole (!steps.t.outputs.token, always() || …) or in the term that reads it (the operand of the nearest && or || around the read, a comparison or function call around it included: steps.t.outputs.x == '' in steps.t.outputs.x == '' && …; false instead under an odd number of !: steps.t.outputs.x == 'true' in !(steps.t.outputs.x == 'true' || …)), or through a job output that is then '' and read one of those ways: the workflow then expects the step to be skipped. A step without an id, a job's if:, a condition that is false when the step was skipped (!(steps.t.outputs.x == '')), or a step whose outputs are also read as they are or gate another step (if: steps.t.outputs.changed == 'true', also with || inputs.force: skipped silently too) is still reported. Nor are inputs every local caller passes reported, unless the workflow can be dispatched or the unit is published (by default the root action.yml and reusable workflows whose file name does not start with _; see impact.publish), since callers in other repositories can still omit them. A default that is '' (default: '', default: ${{ '' }}) counts as none. To accept the rule for one input in every workflow, use an override with target: '**#inputs.<name>'. Not reported in generated files, which are not edited by hand.

Accept one finding

When a finding is intended, accept it with a reason rather than turning the rule off. It is listed apart from the other findings, and does not fail the build.

On its line, with an ignore comment alone on the line above it (the editor's quick fix adds it there) or at the end of the line, after any other comment such as a version (# v4.3.0 # flowpact: ignore[FP105] why):

.github/workflows/ci.yml
# flowpact: ignore[FP105] why it is acceptable here
<the line of the finding>

In the config, with an override, which can expire:

.github/flowpact/flowpact.config.yml
overrides:
  - rule: FP105
    target: <the finding's symbol>
    reason: Why it is acceptable here, at least 10 characters.
    expires: YYYY-MM-DD   # optional

target is the symbol the finding is about; to list them:

flowpact lint --format json | jq -r '.findings[] | select(.code == "FP105") | .symbol'

* matches within a path segment and ** across segments, so one entry accepts every finding whose symbol matches: target: '**#inputs.app-id' is that input in every workflow and action.

Change the severity

Change the severity (or turn the rule off) in .github/flowpact/flowpact.config.yml, by code or by name:

.github/flowpact/flowpact.config.yml
rules:
  FP105: off
  # or: optional-input-no-default-in-condition: error

Explain it in the terminal:

flowpact explain FP105
  • FP107 optional-forwarded-to-required: A required input of a callee is fed from an optional input that is '' when omitted (no default, or default: '').
  • FP401 empty-binding-for-matrix-combo: An input passed under with: is empty for some matrix combinations because a matrix key is missing there.

On this page