mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-06 20:02:11 +02:00
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:
parent
cfbd5b9079
commit
08f69007c9
1 changed files with 3 additions and 3 deletions
|
|
@ -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", ""),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue