@@ -209,38 +209,36 @@ async def resubmit_items(request: Request):
209209
210210@app .post ("/logstatus" )
211211async def logstatus (request : Request ):
212+ """
213+ Log the status of a file upload to CosmosDB.
214+
215+ Parameters:
216+ - request: Request object containing the HTTP request fields:
217+ path, status, status_classification, state.
218+
219+ Returns:
220+ - A dictionary with the status code 200 if successful, or an error
221+ message with status code 500 if an exception occurs.
222+ """
212223 try :
213- # Log the raw request headers
214- log .info (f"/logstatus request headers: { dict (request .headers )} " )
215-
216- # Attempt to read the raw body
217- body = await request .body ()
218- log .info (f"/logstatus raw body: { body .decode ('utf-8' , errors = 'ignore' )} " )
219-
220- # Attempt to parse the JSON body
221- try :
222- json_body = await request .json ()
223- log .info (f"/logstatus parsed JSON body: { json_body } " )
224- except Exception as parse_error :
225- log .error (f"/logstatus failed to parse JSON: { parse_error } " )
226-
227- document_path = json_body .get ("document_path" )
224+ json_body = await request .json ()
225+ path = json_body .get ("path" )
228226 status = json_body .get ("status" )
229227 status_classification = StatusClassification [json_body .get ("status_classification" ).upper ()]
230228 state = State [json_body .get ("state" ).upper ()]
231229
232230 # Add validation to ensure required fields are present
233- if not document_path :
234- raise HTTPException (status_code = 400 , detail = "document_path is required and cannot be null." )
231+ if not path :
232+ raise HTTPException (status_code = 400 , detail = "path is required and cannot be null." )
235233 if not status :
236234 raise HTTPException (status_code = 400 , detail = "status is required and cannot be null." )
237235
238- statusLog .upsert_document (document_path = document_path ,
236+ statusLog .upsert_document (document_path = path ,
239237 status = status ,
240238 status_classification = status_classification ,
241239 state = state ,
242240 fresh_start = True )
243- statusLog .save_document (document_path = document_path )
241+ statusLog .save_document (document_path = path )
244242
245243 return {"message" : "Status logged successfully." }
246244 except Exception as ex :
0 commit comments