Poller: final review fixes (no secret in the image, Storage's real error read, non-http attachment skipped, failing conversation named, duplicate message saved once)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-24 17:00:53 +01:00
1 parent d80b6face8
commit b9dddaf221
8 files changed
+121 -34

No files matched your search

+29 -3
View File
@@ -81,12 +81,38 @@ class TestPoll(unittest.TestCase):
self.assertTrue(any("skipped: 404" in l for l in self.lines))
self.assertIn("conversations", self.sb.tables["checkpoints"])
def test_attachment_refused_by_storage_skipped(self):
self.sb.fail["/storage/v1/object/attachments/"] = 413
def test_attachment_refused_by_storage_skipped(self): # Storage answers 400, the real reason in the body
self.sb.fail["/storage/v1/object/attachments/"] = (400, {"statusCode": "413", "code": "EntityTooLarge"})
self.assertEqual(self.run_once(), 2)
self.assertTrue(any("skipped: 413" in l for l in self.lines))
self.assertTrue(any("skipped: 400 EntityTooLarge" in l for l in self.lines))
self.assertIn("conversations", self.sb.tables["checkpoints"])
def test_missing_bucket_stops_the_run(self): # not an attachment's fault: never skip and lose them all
self.sb.fail["/storage/v1/object/attachments/"] = (400, {"statusCode": "404", "code": "NoSuchBucket"})
with self.assertRaises(urllib.error.HTTPError) as cm:
self.run_once()
cm.exception.close()
self.assertNotIn("conversations", self.sb.tables["checkpoints"])
def test_non_http_attachment_skipped(self): # Lecteur refuses it (ValueError): skipped, never blocks the runs
self.serve(piece("passwd", "file:///etc/passwd", uuid="a1"))
self.assertEqual(self.run_once(), 2)
self.assertTrue(self.sb.tables["messages"]["m08:00"]["raw"]["attachments"][0]["absent"])
self.assertIn("conversations", self.sb.tables["checkpoints"])
def test_failure_names_the_conversation(self):
self.sb.fail["/rest/v1/messages"] = 500
with self.assertRaises(urllib.error.HTTPError) as cm:
self.run_once()
cm.exception.close()
self.assertTrue(any("#2" in l and "u2" in l for l in self.lines))
def test_same_message_twice_saved_once(self): # a page shift while a long thread is read repeats a message
m = message("09:00")
self.ld.reponses[("GET", "/api/v1/conversations/u1/messages")] = pages([m, dict(m)])
self.assertEqual(self.run_once(), 2)
self.assertEqual(self.sb.tables["messages"]["m09:00"]["conversation_uuid"], "u1")
def test_other_storage_error_stops_the_run(self): # a passing failure: the next run starts again
self.sb.fail["/storage/v1/object/attachments/"] = 500
with self.assertRaises(urllib.error.HTTPError) as cm: