From c7f78096ef4f976fe871cc974d34528ffa659834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Guillaume?= <62661249+leoguillaume@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:45:50 +0100 Subject: [PATCH] fix: upload json non string (#111) Co-authored-by: leoguillaume --- app/helpers/data/parsers/_jsonparser.py | 2 +- app/schemas/files.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/data/parsers/_jsonparser.py b/app/helpers/data/parsers/_jsonparser.py index a06bef52..a8d6a2f9 100644 --- a/app/helpers/data/parsers/_jsonparser.py +++ b/app/helpers/data/parsers/_jsonparser.py @@ -31,7 +31,7 @@ def parse(self, file: UploadFile) -> List[ParserOutput]: try: file = JsonFile(documents=file) except Exception as e: - raise InvalidJSONFormatException() + raise InvalidJSONFormatException(detail=f"Invalid JSON file format: {e}") output = list() created_at = round(time.time()) diff --git a/app/schemas/files.py b/app/schemas/files.py index 622ad7d2..23d89dcb 100644 --- a/app/schemas/files.py +++ b/app/schemas/files.py @@ -1,5 +1,5 @@ -from typing import List, Literal, Optional import json +from typing import Dict, List, Literal, Optional from uuid import UUID from pydantic import BaseModel, Field, field_validator, model_validator @@ -43,7 +43,7 @@ def convert_to_string(cls, collection): class Json(BaseModel): title: str text: str - metadata: dict = {} + metadata: Dict[str, str] = {} class JsonFile(BaseModel):