From 66043139ab3e6c5b3e8f324ff8639b2ad4ba5352 Mon Sep 17 00:00:00 2001 From: Phonkd Date: Wed, 22 Jul 2026 23:22:22 +0200 Subject: [PATCH] claude ingest: tolerate a null file_name in the export A Claude.ai export can carry a files/attachments entry whose file_name key is present but explicitly null (a file shared without a name). `dict.get("file_name", "?")` only substitutes the default for a *missing* key, so the null flowed into `", ".join(files)` and crashed the whole ingest with `TypeError: sequence item 0: expected str instance, NoneType found`. Fall back with `or "?"` so the placeholder is still produced. Co-Authored-By: Claude Opus 4.8 --- src/slop_trove/ingest/claude.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slop_trove/ingest/claude.py b/src/slop_trove/ingest/claude.py index 7af471d..fb62646 100644 --- a/src/slop_trove/ingest/claude.py +++ b/src/slop_trove/ingest/claude.py @@ -58,8 +58,11 @@ def _message_text(m: dict) -> str: ] if parts: return "\n".join(parts) - files = [f.get("file_name", "?") for f in (m.get("files") or [])] + [ - a.get("file_name", "?") for a in (m.get("attachments") or []) + # `.get("file_name", "?")` only defaults a *missing* key; an export can + # carry the key with an explicit null (a file shared without a name), so + # fall back with `or` to keep join() from choking on a NoneType. + files = [f.get("file_name") or "?" for f in (m.get("files") or [])] + [ + a.get("file_name") or "?" for a in (m.get("attachments") or []) ] if files: return f"[shared file(s): {', '.join(files)}]"