Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 3bcdd33

Browse files
authored
Make cleanups fixture logging actionable (#13553)
1 parent b036444 commit 3bcdd33

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

localstack-core/localstack/testing/pytest/fixtures.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,8 +2135,28 @@ def cleanups():
21352135
for cleanup_callback in cleanup_fns[::-1]:
21362136
try:
21372137
cleanup_callback()
2138+
except ClientError as e:
2139+
http_code = e.response["ResponseMetadata"]["HTTPStatusCode"]
2140+
# Covers non-standardized error codes such as NotFoundException, NoSuchEntity (IAM), NoSuchBucket (S3), etc
2141+
if http_code == 404:
2142+
LOG.warning(
2143+
"Failed to execute cleanup because a resource was not found. "
2144+
"This cleanup might be unnecessary. %s",
2145+
str(e),
2146+
exc_info=e,
2147+
)
2148+
else:
2149+
LOG.warning(
2150+
"Failed to execute cleanup due to ClientError: %s",
2151+
str(e),
2152+
exc_info=e,
2153+
)
21382154
except Exception as e:
2139-
LOG.warning("Failed to execute cleanup", exc_info=e)
2155+
LOG.warning(
2156+
"Failed to execute cleanup due to unexpected error: %s",
2157+
str(e),
2158+
exc_info=e,
2159+
)
21402160

21412161

21422162
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)