Loading case detail
A pull request stores idempotency responses under the raw key only, so two tenants reusing the same idempotency key can observe each other's cached responses.
--- a/app/idempotency.py +++ b/app/idempotency.py @@ -1,9 +1,9 @@ class IdempotencyStore: def __init__(self): - self._records: dict[tuple[str, str], dict] = {} + self._records: dict[str, dict] = {} def lookup(self, tenant_id: str, key: str): - return self._records.get((tenant_id, key)) + return self._records.get(key) def store(self, tenant_id: str, key: str, response: dict): - self._records[(tenant_id, key)] = response + self._records[key] = response
pytest -q tests--- a/app/idempotency.py +++ b/app/idempotency.py @@ -1,9 +1,9 @@ class IdempotencyStore: def __init__(self): - self._records: dict[str, dict] = {} + self._records: dict[tuple[str, str], dict] = {} def lookup(self, tenant_id: str, key: str): - return self._records.get(key) + return self._records.get((tenant_id, key)) def store(self, tenant_id: str, key: str, response: dict): - self._records[key] = response + self._records[(tenant_id, key)] = response