Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(storage): stop reporting empty s3 listings as exceptions (#109826)

posthog[bot]aa8e9e24c827
diff --git a/posthog/storage/object_storage.py b/posthog/storage/object_storage.py
index 2ae2879ab8c9..af38295b7c11 100644
--- a/posthog/storage/object_storage.py
+++ b/posthog/storage/object_storage.py
@@ -275,10 +275,6 @@ class ObjectStorage(ObjectStorageClient):
if s3_response.get("Contents"):
return [obj["Key"] for obj in s3_response["Contents"]]
else:
- capture_exception(
- Exception("object_storage.no_contents_found_list_objects_in_bucket"),
- {"bucket": bucket, "prefix": prefix},
- )
logger.info("object_storage.no_contents_found_list_objects_in_bucket", bucket=bucket, prefix=prefix)
return None
except Exception as e:
diff --git a/posthog/storage/test/test_object_storage.py b/posthog/storage/test/test_object_storage.py
index f98473fe03a7..32b500619c9f 100644
--- a/posthog/storage/test/test_object_storage.py
+++ b/posthog/storage/test/test_object_storage.py
@@ -165,13 +165,15 @@ class TestStorage(APIBaseTest):
"test_storage_bucket/a_shared_prefix/c",
]
- def test_can_list_unknown_prefix(self) -> None:
+ @patch("posthog.storage.object_storage.capture_exception")
+ def test_can_list_unknown_prefix(self, mock_capture_exception) -> None:
with self.settings(OBJECT_STORAGE_ENABLED=True):
shared_prefix = str(uuid.uuid4())
listing = list_objects(prefix=shared_prefix)
assert listing is None
+ mock_capture_exception.assert_not_called()
def test_can_copy_objects_between_prefixes(self) -> None:
with self.settings(OBJECT_STORAGE_ENABLED=True):