---
title: "The log says failed and the step is green | Proofline"
description: "Look for a pipe."
url: https://proofline.sh/learn/pipeline-hides-test-exit-code/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# The log says failed and the step is green

Look for a pipe. In a shell pipeline the exit status is the last command's, so npm test | tee test.log reports success when tee succeeds, whatever the tests did.

Code review The Proofline team November 24, 2026 3 min read

## Reproduce it in one line

```
bash -c 'false | tee o.log; echo $?'                    # 0
bash -c 'set -o pipefail; false | tee o.log; echo $?'   # 1
```

`pipefail` is not available in every shell. With `dash`, which is `sh` on Debian and Ubuntu, `set -o pipefail` printed `Illegal option -o pipefail` in dash 0.5.12.

## GitHub Actions has two bash defaults

The [workflow syntax reference](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax) lists the command behind each `shell` value on Linux and macOS:

| Setting | Command run | `pipefail` |
| --- | --- | --- |
| No `shell` | `bash -e {0}` | Off |
| `shell: bash` | `bash --noprofile --norc -eo pipefail {0}` | On |

The same `run` line can be green under the first and red under the second. Set it once for the job:

```
defaults:
  run:
    shell: bash
```

`pipefail` can also turn a working step red. `grep` exits 1 when nothing matches, and `some_command | head -1` can end the first command with a broken pipe. Fix those lines individually instead of leaving the setting off.

## Other ways to lose the status

| Pattern | What is reported |
| --- | --- |
| `npm test; echo done` | The status of `echo`, unless the shell runs with `-e` |
| `npm test \|\| true` | Always 0 |
| `result=$(npm test)` followed by a check of `$result` | The text, and not the status, unless the script reads `$?` first |
| `local out=$(npm test)` | The status of `local`, which is 0 |
| A container started in the background | The start, and not the process inside |

## Hand over the status with the log

Write it into the file, from the command itself:

```
set -o pipefail
npm test 2>&1 | tee test.log
status=$?
echo "exit $status at $(date -u +%FT%TZ) on $(git rev-parse HEAD)" | tee -a test.log
exit "$status"
```

A receiver who gets only a log has to infer the result from its text. Logs from tests often print errors on purpose, for example a test of the error path, so "there is an error in the log" and "the run failed" are different statements. The last line settles which one is true.

Under `bash -e`, the script stops at the failing pipeline before the `status` line. Use `if npm test 2>&1 | tee test.log; then …` or `set +e` around it when the record must be written either way.

## Decide

| Log | Step | Next |
| --- | --- | --- |
| Failure summary from the runner | Green | Rerun without the pipe. Treat the result as failed until then |
| Error text, and the runner's summary says passed | Green | Probably an expected error. Find the test that prints it |
| No summary at all | Green | The runner may not have finished. Find the exit code or rerun |

## Worked example

This example is fictional. A release note links a green check and a log whose last lines say `3 failed, 415 passed`. The step piped into `tee` with no `shell` set. Adding `shell: bash` turns the next run red on the same commit. Ben looks back at earlier runs' logs, and the same three tests had been failing for nine days. The decision is no longer about this release alone.

A pass can also come from [running no tests](/learn/filtered-test-run-zero-tests/). Return to [handing over evidence](/learn/engineering-handoff-evidence/).

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [The test command passed because it ran no tests](/learn/filtered-test-run-zero-tests/)
    
    Code review The Proofline team November 24, 2026 3 min read
    
-   ### [The rerun passed: what did it run on?](/learn/rerun-passed-handoff/)
    
    Code review The Proofline team November 24, 2026 3 min read
