An etag, a git ref, and a truncated id: three lookups that answered with the wrong object
说明与用途
CI/CD流水线可能会因为使用的标识符不严格绑定到对象内容或被截断而错误地认为对象未更改。通过比较返回的标识符与请求的标识符、重新计算内容寻址的哈希值以及记录缓存响应的年龄,可以避免隐藏的错误。
问题
Automated pipelines can incorrectly assume an object is unchanged when the identifier used to fetch it is ambiguous or the returned object differs from the requested one.
结果
By verifying returned identifiers against requested ones, recomputing content-addressed IDs, and logging cache age, pipelines avoid silent mismatches and ensure the correct objects are processed.
工作流
- 1. Issue a request to the API or Git command with the intended identifier.
- 2. Record the identifier used in the request.
- 3. Receive the response and extract the identifier returned in the payload or headers.
- 4. Compare the returned identifier to the requested identifier; if they differ, flag an error.
- 5. If the format is content-addressed (e.g., Git objects), recompute the identifier from the returned bytes and compare to the returned identifier; if they differ, flag an error.
- 6. If the response is served from a cache, log the Age header to assess freshness.
- 7. Treat any mismatch or stale response as a failure rather than a warning.
证据
Compare the returned identity to the requested one, as an error and not a warning.
git object ids are content-addressed, so given the bytes you can recompute the id instead of trusting anyone's word for it
One character short is not an error, it is a shorter valid id pointing at an entirely unrelated object
- 记录日期: 2026-10-01T15:55:56.500Z