diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4695cdb..b9929c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,8 @@ All notable changes to this project are documented here. The format follows
retried meanwhile, was still executed afterwards: the resource was created behind Terraform's back and the retry
failed with "already exists" (`BucketAlreadyExists`, `ResourceInUseException`). keepstack now checks that the client
is still connected before running a request that waited.
+- Route 53 zone IDs that came out without digits (`ZSOVGDZPSPRJKSM`) were not recognized as generated, so they were
+ not translated after a restart and Terraform saw the zone as deleted (intermittent).
### Added
- `scripts/chaos.py` and a nightly workflow: kill the emulator, keepstack, or everything at once in the middle of
diff --git a/src/keepstack/proxy.py b/src/keepstack/proxy.py
index 6f58b7f..3ea40bf 100644
--- a/src/keepstack/proxy.py
+++ b/src/keepstack/proxy.py
@@ -111,6 +111,12 @@ def same_name_new_suffix(a, b):
return bool(pa) and pa == pb and ta != tb and len(ta) == len(tb) >= 6 and ta.isalnum() and tb.isalnum()
+def same_shape_new_id(a, b):
+ """ZSOVGDZPSPRJKSM vs Z3LV898WM8KOB1A: a random uppercase ID that came out without digits, which id_like() cannot
+ tell from a word. Both responses answer the same request, so a long code that changed is generated."""
+ return a != b and len(a) == len(b) >= 12 and a.isalnum() and b.isalnum() and a.isupper() and b.isupper()
+
+
def b64_blobs(data):
return [m for m in B64_RE.findall(data) if b"+" in m or m.endswith(b"=")]
@@ -154,7 +160,8 @@ def learn(self, orig_resp, new_resp):
pairs = []
for i, j in pairs:
if not (i and a[i - 1].lower() in REQUEST_ID_KEYS) and (
- (id_like(a[i]) and id_like(b[j])) or same_name_new_suffix(a[i], b[j])):
+ (id_like(a[i]) and id_like(b[j])) or same_name_new_suffix(a[i], b[j])
+ or same_shape_new_id(a[i], b[j])):
learned += self._learn_pair(a[i], b[j])
return learned
diff --git a/tests/test_unit.py b/tests/test_unit.py
index 79b8064..c56208b 100644
--- a/tests/test_unit.py
+++ b/tests/test_unit.py
@@ -69,6 +69,21 @@ def test_secret_suffix_in_a_single_case(self): # regression #24: SGAEFE was not
self.assertEqual(m.to_emulator(b"SecretId=demo-db-password-" + old), b"SecretId=demo-db-password-" + new)
self.assertEqual(m.to_client(b"secret:demo-db-password-" + new), b"secret:demo-db-password-" + old)
+ def test_route53_zone_id_without_digits(self): # regression #36: ZSOVGDZPSPRJKSM was not translated
+ for old, new in ((b"ZSOVGDZPSPRJKSM", b"Z3LV898WM8KOB1A"), (b"Z3LV898WM8KOB1A", b"ZQWERTYUIOPASDF")):
+ m = IdMap()
+ m.learn(b"/hostedzone/%sdemo.internal." % old,
+ b"/hostedzone/%sdemo.internal." % new)
+ self.assertEqual(m.to_emulator(b"/2013-04-01/hostedzone/" + old), b"/2013-04-01/hostedzone/" + new)
+ self.assertEqual(m.to_client(b"/hostedzone/" + new), b"/hostedzone/" + old)
+
+ def test_short_or_numeric_codes_are_not_ids(self):
+ m = IdMap()
+ # Long AWS enums use underscores; shorter codes and plain numbers are not IDs either.
+ m.learn(b'{"State":"CREATE_IN_PROGRESS","Alarm":"INSUFFICIENT_DATA","Code":"ABCDEFGHIJK","N":"123456789012"}',
+ b'{"State":"CREATE_COMPLETE_OK","Alarm":"OK_STATE_REACHED_","Code":"ZYXWVUTSRQP","N":"999999999999"}')
+ self.assertEqual(m.to_new, {})
+
def test_status_changes_are_not_suffixes(self):
# Recorded and replayed responses answer the same request, so names match; what changes between them is
# generated values and statuses. Statuses use underscores or have a different length.