CircleCI "when" Condition Invalid Logic
CircleCI logic statements (and, or, not, equal, matches) gate steps, jobs, or workflows. A malformed structure, wrong nesting, or comparing the wrong values produces an invalid config or a condition that never matches.
What this error means
Config processing fails on a when/unless block, or the gated step/job is unexpectedly always or never run.
circleci
Error: when clause in job deploy is invalid.
'equal' expects a list of values to compare, got a mapping.Common causes
Malformed logic operator
equal expects a list, and/or expect lists of conditions; passing the wrong shape fails.
Comparing an unexpanded parameter
Using a pipeline parameter that resolves to empty makes the comparison false.
Steps where a condition belongs
Putting steps directly under when instead of under a condition plus steps is invalid for step-level when.
How to fix it
Use the correct logic shape
Provide equal a list and nest steps under condition correctly.
.circleci/config.yml
steps:
- when:
condition:
equal: [main, << pipeline.git.branch >>]
steps:
- run: ./deploy.shHow to prevent it
- Give equal a list of values to compare.
- Verify pipeline parameters resolve before comparing.
- Nest steps under condition for step-level when.
Related guides
CircleCI "parameter X is not declared" ErrorFix CircleCI parameter X is not declared - a job, command, or executor uses a parameter that was never declar…
CircleCI "matrix parameters must be declared" ErrorFix CircleCI matrix errors where matrix parameters are not declared on the target job - every matrix key must…
CircleCI "Workflow halted" - Job Requires ApprovalFix CircleCI workflows that stop and wait - an approval job pauses the workflow until someone approves, so do…