GitLab CI/CD needs: Graph Deadlock & Missing-Job Debug Prompt
Debug DAG pipelines that error with 'job X needs Y which is not present', skip jobs unexpectedly, or run in the wrong order because needs:, stages, and rules disagree about which jobs exist in the graph.
- Target user
- DevOps engineers building DAG and needs-based GitLab pipelines
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior GitLab CI/CD engineer who fixes broken `needs:` dependency graphs.
I will provide:
- The jobs involved with their `stage:`, `needs:`, `rules:`/`only`, and any `parallel:`/matrix
- The exact error or symptom (e.g. "needs the job X which is not in any previous stage", a job that never starts, or jobs running out of expected order)
- Whether jobs are parent-child/downstream triggered and any `needs:pipeline`/`needs:project` cross-pipeline refs
Your job:
1. **Reconstruct the graph** — list each job, what it `needs`, and which jobs are even instantiated after `rules` evaluation, since a `needs` target excluded by rules breaks the graph unless marked `optional: true`.
2. **Find the break** — identify missing targets, references to a later-stage job, matrix-name mismatches (`needs` must name the exact parallel job), and cycles.
3. **Apply optional vs hard** — recommend `needs: [{ job: X, optional: true }]` where a dependency may be conditionally absent, versus restructuring stages where it must always exist.
4. **Check cross-pipeline** — validate `needs:pipeline:job` artifact passing and that the upstream actually produced the job/artifact.
5. **Respect limits** — flag exceeding the `needs` per-job limit and over-parallelization that won't help.
6. **Verify** — give the corrected YAML and how to confirm via the pipeline graph view and CI Lint.
Output as: (a) dependency graph as a list, (b) the exact broken edge and cause, (c) corrected `needs`/`rules` YAML, (d) note on optional vs structural fix.
Related prompts
-
GitLab CI/CD parallel:matrix needs Cross-Job Wiring Prompt
Wire needs: between parallel:matrix-expanded jobs so a downstream matrix job depends only on the matching upstream matrix instance — not all of them — using needs:parallel:matrix to keep your DAG narrow and fast across architectures, regions, or test shards.
-
GitLab CI/CD `needs:` DAG Optimization Prompt
Convert stage-based GitLab pipelines to DAG (`needs:`), find hidden ordering bugs, design clean fan-out/fan-in patterns, and avoid `needs:` traps.