fix(cloudfront): report stale issued store versions as failed preconditions (#8514)

UpdateKeyValueStore and DeleteKeyValueStore answered every If-Match that
did not match the store's control-plane ETag with InvalidIfMatchVersion
(400). A stale version Floci issued, one that a comment update has since
rotated, now fails with PreconditionFailed (412); a missing or malformed
version keeps InvalidIfMatchVersion. A refused request leaves the store
and its data plane unchanged, and the CloudFront overview and the
key-value-store section of the docs describe the same statuses.

Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
Jackson PriceandAndre Kurait authored and GitHub committed 2026-11-15 18:39:09 -04:00
1 parent e1c3242978
commit f3a0595f50
4 files changed
+166 -5

No files matched your search

@@ -43,6 +43,8 @@ public class CloudFrontKeyValueStoreService implements StoredResourceArns {
static final int MAX_STORES = 200;
private static final Pattern STORE_NAME = Pattern.compile("[a-zA-Z0-9_-]{1,64}");
private static final Pattern ISSUED_ETAG = Pattern.compile(
"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}");
private static final int MAX_COMMENT_LENGTH = 128;
private static final String STATUS_READY = "READY";
@@ -273,10 +275,15 @@ public class CloudFrontKeyValueStoreService implements StoredResourceArns {
}
private static void requireControlPlaneEtag(KeyValueStore kvs, String ifMatch) {
if (ifMatch == null || !kvs.getEtag().equals(ifMatch)) {
if (kvs.getEtag().equals(ifMatch)) {
return;
}
if (ifMatch == null || !ISSUED_ETAG.matcher(ifMatch).matches()) {
throw new AwsException("InvalidIfMatchVersion",
"The If-Match version is missing or not valid for the resource.", 400);
}
throw new AwsException("PreconditionFailed",
"The precondition in the If-Match header did not match the current resource.", 412);
}
private static void requireDataPlaneEtag(KeyValueStore kvs, String ifMatch) {