Skip to content

Commit 29a22c6

Browse files
fix: Minor error handling in metadata read, log fix in index (#21)
Minor error handling in metadata read, log fix in index
1 parent 1ed1ad7 commit 29a22c6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/unstract/sdk/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def index_file(
281281
raise SdkError(f"Error adding nodes to vector db: {e}")
282282
self.tool.stream_log("Added nodes to vector db")
283283

284-
self.tool.stream_log("Done indexing file")
284+
self.tool.stream_log("File has been indexed successfully")
285285
return doc_id
286286

287287
@staticmethod

src/unstract/sdk/tool/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
import json
33
from abc import ABC, abstractmethod
4-
from json import loads
4+
from json import JSONDecodeError, loads
55
from pathlib import Path
66
from typing import Any, Union
77

@@ -170,6 +170,10 @@ def _get_exec_metadata(self) -> dict[str, Any]:
170170
try:
171171
with open(metadata_path, encoding="utf-8") as f:
172172
metadata_json = loads(f.read())
173+
except JSONDecodeError as e:
174+
self.stream_error_and_exit(
175+
f"JSON decode error for {metadata_path}: {e}"
176+
)
173177
except FileNotFoundError:
174178
self.stream_error_and_exit(
175179
f"Metadata file not found at {metadata_path}"

0 commit comments

Comments
 (0)