File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed
Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change 6464 description : ok
6565 " 400 " :
6666 description : Bad request
67+ " 422 " :
68+ description : If no text has been extracted from the file.
6769 " 500 " :
6870 description : Internal server error
6971 tags :
Original file line number Diff line number Diff line change 1111from admin_api_lib .apis .admin_api_base import BaseAdminApi
1212from admin_api_lib .models .document_status import DocumentStatus
1313
14+
1415router = APIRouter ()
1516
1617ns_pkg = admin_api_lib .impl
@@ -129,6 +130,7 @@ async def load_confluence_post() -> None:
129130 responses = {
130131 200 : {"description" : "ok" },
131132 400 : {"description" : "Bad request" },
133+ 422 : {"description" : "If no text has been extracted from the file." },
132134 500 : {"description" : "Internal server error" },
133135 },
134136 tags = ["admin" ],
Original file line number Diff line number Diff line change @@ -161,6 +161,10 @@ async def _aparse_document(
161161 self ._key_value_store .upsert (filename , Status .PROCESSING )
162162
163163 information_pieces = self ._document_extractor .extract_from_file_post (ExtractionRequest (path_on_s3 = filename ))
164+ if not information_pieces :
165+ self ._key_value_store .upsert (filename , Status .ERROR )
166+ logger .error ("No information pieces found in the document: %s" , filename )
167+ raise HTTPException (status_code = status .HTTP_422_UNPROCESSABLE_ENTITY , detail = "No information pieces found" )
164168 documents = [self ._information_mapper .extractor_information_piece2document (x ) for x in information_pieces ]
165169 host_base_url = str (request .base_url )
166170 document_url = f"{ host_base_url .rstrip ('/' )} /document_reference/{ urllib .parse .quote_plus (filename )} "
You can’t perform that action at this time.
0 commit comments