cicd config_error ai_generated true

Warning: Cache 'node-modules-v1' not found for key 'node-modules-v1-abc123'. Restoring from fallback.

ID: cicd/bitbucket-pipeline-artifact-cache-key-mismatch

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2024-04-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Bitbucket Pipelines 2.0+ active
bitbucket-pipelines.yml schema v2 active

Root Cause

Bitbucket Pipelines cannot find a cache entry for the given key because the cache was evicted, the key format has changed, or the cache was never created due to a failed step.

generic

中文

Bitbucket Pipelines 无法找到给定键的缓存条目,因为缓存被逐出、键格式已更改,或由于步骤失败而从未创建缓存。

Official Documentation

https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/

Workarounds

  1. 80% success Update the cache key in bitbucket-pipelines.yml to use a dynamic hash based on the lock file: `caches: node-modules: key: node-modules-v1-{{ checksum "package-lock.json" }}`
    Update the cache key in bitbucket-pipelines.yml to use a dynamic hash based on the lock file: `caches: node-modules: key: node-modules-v1-{{ checksum "package-lock.json" }}`
  2. 90% success Add a fallback cache key to restore from a previous cache: `caches: node-modules: key: node-modules-v1-{{ checksum "package-lock.json" }} restore-keys: node-modules-v1-`
    Add a fallback cache key to restore from a previous cache: `caches: node-modules: key: node-modules-v1-{{ checksum "package-lock.json" }} restore-keys: node-modules-v1-`

中文步骤

  1. Update the cache key in bitbucket-pipelines.yml to use a dynamic hash based on the lock file: `caches: node-modules: key: node-modules-v1-{{ checksum "package-lock.json" }}`
  2. Add a fallback cache key to restore from a previous cache: `caches: node-modules: key: node-modules-v1-{{ checksum "package-lock.json" }} restore-keys: node-modules-v1-`

Dead Ends

Common approaches that don't work:

  1. Increasing the cache size limit in the pipeline settings without changing the cache key 50% fail

    The cache key mismatch is unrelated to size; it's a key generation issue that requires updating the cache key format in the YAML.

  2. Manually deleting the cache from the Bitbucket UI and hoping a new one is created automatically 70% fail

    Deleting the cache does not trigger a new cache creation; the pipeline must be re-run with a valid cache step to generate a new entry.