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

+8 -4
View File
@@ -12,7 +12,7 @@ class FakeSupabase:
self.tables: dict[str, dict[str, dict]] = {"conversations": {}, "messages": {}, "checkpoints": {}}
self.objects: dict[str, bytes] = {}
self.requests: list[tuple[str, str, dict]] = [] # (method, path with query, headers with lower-case names)
self.fail: dict[str, int] = {} # path prefix → error code to return
self.fail: dict[str, int | tuple[int, dict]] = {} # path prefix → error code, or (code, body) as Storage does
fake = self
class Handler(BaseHTTPRequestHandler):
@@ -29,9 +29,10 @@ class FakeSupabase:
raw = self.rfile.read(n) if n else b""
fake.requests.append((self.command, self.path, {k.lower(): v for k, v in self.headers.items()}))
url = urllib.parse.urlsplit(self.path)
for prefix, code in fake.fail.items():
for prefix, failure in fake.fail.items():
if url.path.startswith(prefix):
return self._answer(code, {"message": "failure"})
code, body = failure if isinstance(failure, tuple) else (failure, {"message": "failure"})
return self._answer(code, body)
if url.path.startswith("/rest/v1/"):
table = url.path.removeprefix("/rest/v1/")
key = KEYS.get(table, "uuid")
@@ -42,7 +43,10 @@ class FakeSupabase:
if vals[0].startswith("eq."):
rows = [r for r in rows if str(r.get(col)) == vals[0][3:]]
return self._answer(200, rows)
for row in json.loads(raw):
rows = json.loads(raw)
if len({r[key] for r in rows}) < len(rows): # PostgREST: "cannot affect row a second time"
return self._answer(500, {"code": "21000"})
for row in rows:
fake.tables[table][row[key]] = fake.tables[table].get(row[key], {}) | row
return self._answer(201)
if url.path == "/storage/v1/object/list/attachments":