GitHub Actions · infra · fg-0235

Using secrets in an if condition fails with "Unrecognized named-value: 'secrets'"

If you see Unrecognized named-value: 'secrets'. Located at position 1 within expression, the cause and the fix for GitHub Actions are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Unrecognized named-value: 'secrets'. Located at position 1 within expressionWorkflow is invalid before it runsAn if condition that reads secrets.TOKEN is never evaluated
Cause
The secrets context is not allowed in jobs.ID.if or in step if conditions. Only contexts listed for each key are available there.
Fix
Map the secret into env at job level and test env in the step condition.
Apply
jobs: publish: runs-on: ubuntu-latest env: HAS_TOKEN: ${{ secrets.NPM_TOKEN != '' }} steps: - if: env.HAS_TOKEN == 'true' run: npm publish
Affected
GitHub Actions workflow syntax, as of October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun