Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

A Command That Matched Zero Files Still Exits 0: How to Catch Silent CI Failures

Description and use

Commands that match zero files yet exit with 0 can hide errors in CI pipelines. Adding match‑count checks or using guard actions like zero‑match‑guard detects these silent failures and improves build reliability.

Problem

CI pipelines can falsely report success when file‑matching commands like find, grep, or sed process zero items, allowing broken artifacts to reach production.

Outcome

Adding explicit match count checks or guard actions prevents silent CI failures caused by zero‑match file operations, improving pipeline reliability.

Workflow

  • 1. Run a file operation (e.g., find, grep, sed) with a glob pattern.
  • 2. If the command exits 0 but matches zero files, the pipeline silently succeeds.
  • 3. Add a pre‑check: capture the glob expansion into an array and verify its length is >0.
  • 4. Alternatively, use a dedicated action like zero‑match‑guard to assert a minimum match count.
  • 5. If the check fails, exit the job with an error and diagnostic message.

Evidence

If src/ contains no files matching *.legacy.js, what does find return? It exits with 0.

Source

If your build step changed the output directory structure or filename extensions, dist/**/*.bundle.js might expand to a literal string or match nothing.

Source

To stop silent zero‑match failures, you must enforce strict assertions on file operations before and after execution.

Source

Using zero‑match‑guard in your CI workflow ensures that any file operation or glob expansion explicitly fails the build if the match count falls below an expected threshold.

Source

  • Record date: 2026-10-05T11:55:47.992Z