---
title: "MGS3030: pipe upstream failed"
description: A magus stage upstream of this run in a shell pipe exited non-zero. A run that learns it before taking its locks starts nothing; the last stage of a pipeline that succeeded exits with it, so the pipeline fails without set -o pipefail.
tags: [MGS3030, locks, pipe, pipefail, stdin, exit-status]
---

# MGS3030: pipe upstream failed

A shell reports a pipeline's status from its last stage only, unless `set -o
pipefail` is on, and agents never turn it on. So a pipe of magus runs carries the
status forward itself (see
[Piping one magus into another](../../../concepts/concurrency.md#piping-one-magus-into-another)).
Every magus stage whose stdout is a pipe records how it ended, and a run reading
that pipe checks it twice.

Before it takes any lock, a run refuses to start after a proven upstream stage that
has already failed:

```text
[MGS3030] pid 40118 (magus run generate:rw libs/api), upstream of this run in a
  pipe, exited 1, so this run started nothing. A pipeline of magus runs stops at its
  first failed stage: fix that stage, then run the pipeline again.
```

A run that succeeded waits for every proven upstream stage to end before it exits,
and fails with the first one that did not:

```text
[MGS3030] pid 40118 (magus run build libs/api), upstream of this run in a pipe,
  exited 2. This run succeeded, but the pipeline failed at that stage.
```

The exit status is the upstream's own, or 1 when a signal stopped it. A run that
failed reports its own failure instead. An upstream that ended without recording its
status, because it was killed or ran against another workspace, is named on stderr
as unknown and does not fail the run.

## Resolution

- Fix the stage the message names, then run the pipeline again.
- Run that stage on its own to see its failure in full; its output went to stderr
  above the refusal.

## See also

- [MGS3023](MGS3023.md): a pipe whose writers loop back into the run reading it.
- [Concurrency](../../../concepts/concurrency.md#piping-one-magus-into-another): how
  one magus waits on another it reads from.
