3131load_dotenv (env_file_path )
3232
3333# === ENV Setup ===
34+ start_time = datetime .now ()
35+
3436ENV = {
3537 "AZURE_BLOB_STORAGE_ACCOUNT" : os .getenv ("AZURE_BLOB_STORAGE_ACCOUNT" ),
3638 "AZURE_BLOB_STORAGE_ENDPOINT" : os .getenv ("AZURE_BLOB_STORAGE_ENDPOINT" ),
@@ -208,8 +210,21 @@ async def resubmit_items(request: Request):
208210@app .post ("/logstatus" )
209211async def logstatus (request : Request ):
210212 try :
211- json_body = await request .json ()
212- document_path = json_body .get ("document_path" ) # Match the frontend's key
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" )
213228 status = json_body .get ("status" )
214229 status_classification = StatusClassification [json_body .get ("status_classification" ).upper ()]
215230 state = State [json_body .get ("state" ).upper ()]
@@ -221,10 +236,10 @@ async def logstatus(request: Request):
221236 raise HTTPException (status_code = 400 , detail = "status is required and cannot be null." )
222237
223238 statusLog .upsert_document (document_path = document_path ,
224- status = status ,
225- status_classification = status_classification ,
226- state = state ,
227- fresh_start = True )
239+ status = status ,
240+ status_classification = status_classification ,
241+ state = state ,
242+ fresh_start = True )
228243 statusLog .save_document (document_path = document_path )
229244
230245 return {"message" : "Status logged successfully." }
0 commit comments