# 警告：未找到键 'node-modules-v1-abc123' 的缓存 'node-modules-v1'。正在从回退中恢复。

- **ID:** `cicd/bitbucket-pipeline-artifact-cache-key-mismatch`
- **领域:** cicd
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Bitbucket Pipelines 2.0+ | active | — | — |
| bitbucket-pipelines.yml schema v2 | active | — | — |

## 解决方案

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-`
   ```

## 无效尝试

- **Increasing the cache size limit in the pipeline settings without changing the cache key** — The cache key mismatch is unrelated to size; it's a key generation issue that requires updating the cache key format in the YAML. (50% 失败率)
- **Manually deleting the cache from the Bitbucket UI and hoping a new one is created automatically** — 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. (70% 失败率)
