CI/CD / Editorial solution guide
A cache hit produces an inconsistent build
Identify incompatible cached dependencies and verify a clean, bounded rebuild.
Read-only knowledge base · No public comments
Recognize the symptoms
A build passes on one runner but fails or produces different output after restoring a dependency cache. A clean build may behave differently even with the same source revision.
Understand the likely causes
- The cache key or fallback can omit a relevant lockfile, platform or toolchain input; cached paths may include generated state that is not portable. A changed external dependency or undeclared environment input can also explain the difference.
Capture the actual inputs and cache match
Record the source revision, lockfile digest, operating system, architecture, tool versions, resolved cache key and whether the match was exact or a fallback. Preserve sanitized logs and the paths restored without exposing secrets. Compare these facts for a successful and failing run; a shared key or filename is not proof that their contents are compatible. Cache semantics vary by platform, so check the documentation for the runner and cache implementation actually used.
Compare against a clean isolated build
In an authorized disposable runner, build the same revision with the same declared tools and cache disabled, then compare dependency resolution, test results and artifact identity with the cached run. Keep other inputs fixed as far as practical and record any network-resolved dependencies. If both runs fail identically, investigate the source or toolchain rather than blaming the cache. A clean result narrows the hypothesis but does not alone establish which cached file was responsible.
Correct the cache contract
Identify which restored paths are reusable downloads and which contain environment-specific generated output. Update the key or restore policy to include the inputs required by the tool, and rebuild incompatible generated state instead of copying it between environments. Apply cache invalidation only to the affected scope under the platform’s normal procedure. Do not delete unrelated caches or relax dependency verification as a way to make the build pass.
Verify miss, hit and changed input
Run a bounded test sequence in the disposable environment: a clean miss, a subsequent compatible hit, and a run with one relevant input changed. Compare test results and the expected artifact properties at each step, and confirm the changed input cannot reuse incompatible state. Record source, toolchain and cache evidence with the candidate. Reproducibility claims must name which inputs and environments were controlled rather than promising identical output everywhere.
Verify the fix
Confirm the release candidate was produced by the intended revision and verified build after the cache correction. Compare artifact identity and tests with the clean baseline; investigate any difference before promotion.
Keep it from recurring
- Version cache keys with relevant dependency and platform inputs, separate downloads from generated output, and periodically test clean builds. Review cache trust boundaries and avoid storing credentials or sensitive data in reusable paths.