Skip to Content
flowpact

FP302 · output-ref-without-needs

`needs.<job>` is read where the `needs` context does not contain `<job>`.

CodeNameCategoryDefault severityReported by
FP302output-ref-without-needsOutputs🔴 errorlint, check, the action, the editor

What you see

In the deep-nesting fixture:

✖  ERROR  FP302 output-ref-without-needs
  jobs.notify reads needs.build, which is empty here: "build" is not under needs, and only the job's `if:` sees jobs it depends on indirectly
  ▶ .github/workflows/pipeline.yml:39:33

Why it matters

The needs context contains the jobs listed under needs:. Only the job's own if: also sees the jobs it depends on indirectly (through one of its needs); in steps, env, with:, name and the matrix their values are empty. A job that does not depend on <job> at all may also run before it.

How to fix

Add the job to needs: (it is fine to list transitive dependencies explicitly).

Example

deploy:
  needs: test
  run: deploy ${{ needs.build.outputs.version }}

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[FP302] why):

.github/workflows/pipeline.yml
# flowpact: ignore[FP302] why it is acceptable here
- run: echo "deployed ${{ needs.build.outputs.artifact-url }}"

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

.github/flowpact/flowpact.config.yml
overrides:
  - rule: FP302
    target: ".github/workflows/pipeline.yml#jobs.build"
    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 == "FP302") | .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:
  FP302: off
  # or: output-ref-without-needs: error

Explain it in the terminal:

flowpact explain FP302
  • FP301 undefined-output-ref: An expression reads an output (needs.*, jobs.*, steps.*) that is never defined.
  • FP608 undefined-needs-job: A job lists a job under needs: that does not exist.

On this page