---
title: "MGS3029: saved plan refused"
description: A magus run --stdin invocation read a document that is not a shard plan, or named a shard, target or shard count the plan does not have. Nothing runs. Exits 2.
tags: [MGS3029, plan, shard, run --stdin, affected --plan, CI matrix, exit 2]
---

# MGS3029: saved plan refused

`magus run --stdin` runs the shards of a plan that `magus affected <target> --plan`
printed, piped in or redirected from a file. The plan decides the target and the
projects, so anything that would make the run cover a different set from the one the
plan describes is refused before a target starts, and the invocation exits **2**, the
misuse status.

```text
[MGS3029] --shard 9: the plan has no such shard (it has 0, 1, 2)
  see: https://eli.gladman.cc/magus/reference/codes/sandbox/MGS3029/
```

It fires for:

- **A malformed plan.** Stdin is a terminal, empty or not JSON, or the plan has no `target` (one
  printed by a magus older than the key), repeats a shard id, has a shard with no
  projects, or states a `count` that disagrees with its `matrix`.
- **A shard the plan does not have.** `--shard` names a shard id from the plan's
  `matrix`. An inherited plan has no shards at all, so every `--shard` is refused.
- **A different target.** `magus run test --stdin < plan.json` against a plan for `ci`.
  The target positional is optional with `--stdin`; give it only to add charms, as in
  `ci:gha`.
- **A different shard count.** `--n-shards` is implied by the plan. A value that
  disagrees means the caller and the plan describe different matrices.

Each would otherwise run less than the plan, or something other than the plan, and
still exit 0.

## Resolution

- Regenerate the plan with the magus that will run it: `magus affected <target> --plan
  > plan.json`.
- Pick a shard id from the plan's `matrix`. `magus run --stdin --dry-run < plan.json`
  prints each shard's command without running it.
- Drop `--n-shards`, or the target positional, and let the plan supply them.

## See also

- [magus affected](../../manpage/magus-affected.md): computing the plan.
- [magus run](../../manpage/magus-run.md): `--stdin`, `--shard` and `--n-shards`.
- [GitHub Actions](../../../guides/integrations/github-actions.md): publishing a plan
  as a job matrix.
