fix: handle missing time field in library API document/processing responses (#1028)

Documents and processing records without a stored time field caused a
KeyError crash in get_documents and list_children. Use optional access
so time resolves to None instead of failing.
This commit is contained in:
cybermaggedon 2026-07-06 10:47:24 +01:00 committed by GitHub
parent cfbd5b9079
commit 08f69007c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -363,7 +363,7 @@ class Library:
return [ return [
DocumentMetadata( DocumentMetadata(
id = v["id"], id = v["id"],
time = datetime.datetime.fromtimestamp(v["time"]), time = datetime.datetime.fromtimestamp(v["time"]) if "time" in v else None,
kind = v["kind"], kind = v["kind"],
title = v.get("title", ""), title = v.get("title", ""),
comments = v.get("comments", ""), comments = v.get("comments", ""),
@ -678,7 +678,7 @@ class Library:
ProcessingMetadata( ProcessingMetadata(
id = v["id"], id = v["id"],
document_id = v["document-id"], document_id = v["document-id"],
time = datetime.datetime.fromtimestamp(v["time"]), time = datetime.datetime.fromtimestamp(v["time"]) if "time" in v else None,
flow = v["flow"], flow = v["flow"],
collection = v["collection"], collection = v["collection"],
tags = v["tags"], tags = v["tags"],
@ -983,7 +983,7 @@ class Library:
return [ return [
DocumentMetadata( DocumentMetadata(
id=v["id"], id=v["id"],
time=datetime.datetime.fromtimestamp(v["time"]), time=datetime.datetime.fromtimestamp(v["time"]) if "time" in v else None,
kind=v["kind"], kind=v["kind"],
title=v["title"], title=v["title"],
comments=v.get("comments", ""), comments=v.get("comments", ""),