download

CI fails on an untouched branch. How do you debug it?

DevOps~8 minReviewed 2 Dec 2026Free · No sign-in

Question

Commit a91f3c2 passed CI yesterday. Today the exact same commit fails npm test with TypeError: parser.parseV2 is not a function. No one touched the branch. Here is the workflow:

"YAML"
jobs:
  test:
    runs-on: ubuntu-latest
    container: node:20-alpine
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: node_modules
          key: deps-v1
      - run: npm install
      - run: npm test
  1. Which five moving parts in this workflow can break an untouched commit overnight?
  2. How do you isolate the exact culprit first?
  3. How do you fix the workflow so builds stay deterministic?
Show hints (3)
  1. "SPOT FLOATING VERSIONS"

    Check every line that resolves a mutable tag at runtime: ubuntu-latest, node:20-alpine, @v4, and npm install.

  2. "INSPECT CACHE KEY"

    key: deps-v1 never changes when package-lock.json changes, and caching node_modules directly can mix binaries from an older Node build.

  3. "DIFF YESTERDAY VS TODAY"

    Compare the resolved runner image, container digest, cache hit status, and installed package versions between yesterday's passing log and today's failing log.

Show checked explanation

Code stayed fixed, so an unpinned external input moved overnight: ubuntu-latest, mutable node:20-alpine, tag-pinned @v4 actions, a static deps-v1 node_modules cache, or npm install resolving newer transitive packages. Diff yesterday's green log against today's red log, reproduce in the exact container, then pin digests, SHAs, lockfile cache keys, and npm ci.

Broken and fixed GitHub Actions YAML structure, 64-hex image digest and 40-hex commit SHA formats, lockfile cache key, and npm ci command replacement were checked on CPython 3.12.10; runner, cache, and npm ci semantics were checked against GitHub Actions and npm documentation. Checked by an editor other than the author.

Walkthrough

When an untouched commit breaks overnight, stop staring at application code and ask what changed in the build environment. Diff yesterday's passing CI log against today's failing log on four lines: runner image version, pulled container digest (sha256), cache hit/miss, and installed package versions (npm ls). Then pull the exact container digest locally and run the failing test to reproduce cleanly.

This 12-line workflow hides five separate moving parts:

Moving partWhy it breaks overnightDeterministic fix
ubuntu-latestGitHub rotates runner OS releases silentlyPin an explicit OS (ubuntu-24.04)
node:20-alpineMutable tag updates Node and Alpine packagesPin the immutable @sha256:... digest
actions/*@v4Mutable major tag can shift or be compromisedPin a full 40-char commit SHA (# v4)
key: deps-v1 on node_modulesRestores stale modules across lockfile or Node updatesCache ~/.npm keyed by hashFiles('package-lock.json')
npm installDrifts when lockfile is missing, unlocked, or out of sync; keeps stale node_modulesUse npm ci for clean, exact lockfile installs

In this TypeError: parser.parseV2 is not a function failure, suspect stale cached node_modules from deps-v1 or npm install resolving a newer package when the lockfile is missing, unlocked, or out of sync. In npm v7+, npm install respects an in-sync lockfile, yet still keeps stale node_modules and rewrites the lockfile on drift. npm ci wipes node_modules, installs exact lockfile versions, and fails fast on any mismatch.

Here is the hardened, repeatable job:

"YAML"
jobs:
  test:
    runs-on: ubuntu-24.04
    container: node@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
      - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
        with:
          path: ~/.npm
          key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
      - run: npm ci
      - run: npm test

Pair SHA pinning with automated update PRs (like Dependabot) so security updates still land cleanly through normal CI checks instead of breaking main at random.

Common mistakes

  • Clicking 'Re-run jobs' three times and assuming the test is flaky. If an unpinned dependency or base image broke, retries waste time and mask supply-chain drift.
  • Using npm install in CI instead of npm ci. npm install can silently upgrade unlocked ranges and ignore stale files sitting inside cached node_modules.
  • Caching node_modules with a fixed key like deps-v1. Native addons compiled under one Node version break when the container updates.
  • Deleting the lockfile to make CI pass. That discards reproducible versions and pushes an untested dependency tree to production.

Follow-up questions

  • "Why pin third-party GitHub Actions to a 40-character commit SHA instead of @v4?" Git tags like @v4 are mutable pointers. An upstream maintainer or attacker who gains repo access can move @v4 to new commits with access to your CI secrets. A full commit SHA is immutable.
  • "What if the failure still happens after pinning dependencies, images, and caches?" Check time-dependent inputs: an expired TLS certificate or test token, a hardcoded date in a unit test, an external API mock or rate limit, or runner clock/timezone assumptions.

What a strong answer covers

Identifies all five unpinned inputs (ubuntu-latest, mutable image tag, @v4 action tags, static node_modules cache, and npm install). Starts by diffing yesterday's passing log against today's failing log, reproduces locally, and pins digests, commit SHAs, lockfile cache keys, and npm ci.

Open in interactive practice deck →

Original OfferVibe question. Secure use of GitHub Actions · Dependency caching · npm ci.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.