@@ -206,15 +206,15 @@ def check_all_sections_complete(document_id, tracking_table):
206206 if not sections :
207207 return False , False
208208
209- has_Failed_sections = False
209+ has_failed_sections = False
210210 for section in sections :
211211 status = section .get ('Status' )
212- if status == 'Failed ' :
213- has_Failed_sections = True
214- elif status != 'Completed ' :
212+ if status == 'FAILED ' :
213+ has_failed_sections = True
214+ elif status != 'COMPLETED ' :
215215 return False , False # Still has pending sections
216216
217- return True , has_Failed_sections
217+ return True , has_failed_sections
218218 except Exception as e :
219219 logger .error (f"Error checking section completion status: { str (e )} " )
220220 return False , False
@@ -438,28 +438,28 @@ def lambda_handler(event, context):
438438 update_token_status (section_token_id , section_status , section_failure_reason , tracking_table )
439439
440440 # Check if all sections for this document are complete
441- all_sections_complete , has_Failed_sections = check_all_sections_complete (document_id , tracking_table )
441+ all_sections_complete , has_failed_sections = check_all_sections_complete (document_id , tracking_table )
442442
443443 if all_sections_complete :
444444 section_task_token = find_doc_task_token (document_id , tracking_table )
445445
446446 if section_task_token :
447- if has_Failed_sections :
448- # Collect all Failed pages for failure message
449- all_Failed_pages = []
447+ if has_failed_sections :
448+ # Collect all failed pages for failure message
449+ all_failed_pages = []
450450 response = tracking_table .scan (
451- FilterExpression = "begins_with(PK, :prefix) AND TokenType = :type AND (#status = :Failed_status OR #status = :Stopped_status )" ,
451+ FilterExpression = "begins_with(PK, :prefix) AND TokenType = :type AND (#status = :failed_status OR #status = :stopped_status )" ,
452452 ExpressionAttributeNames = {'#status' : 'Status' },
453453 ExpressionAttributeValues = {
454454 ':prefix' : f"HITL#{ document_id } #section#" ,
455455 ':type' : 'HITL_PAGE' ,
456- ':Failed_status ' : 'Failed ' ,
457- ':Stopped_status ' : 'Stopped '
456+ ':failed_status ' : 'FAILED ' ,
457+ ':stopped_status ' : 'STOPPED '
458458 }
459459 )
460460
461461 for item in response .get ('Items' , []):
462- all_Failed_pages .append ({
462+ all_failed_pages .append ({
463463 'execution_id' : execution_id ,
464464 'record_id' : item .get ('SectionId' ),
465465 'page_id' : item .get ('PageId' ),
@@ -470,7 +470,7 @@ def lambda_handler(event, context):
470470 stepfunctions .send_task_failure (
471471 taskToken = section_task_token ,
472472 error = 'HITLFailedException' ,
473- cause = f"HITL review Failed for { len (all_Failed_pages )} page(s): { json .dumps (all_Failed_pages )} "
473+ cause = f"HITL review failed for { len (all_failed_pages )} page(s): { json .dumps (all_failed_pages )} "
474474 )
475475 logger .info (f"Sent task failure for execution { execution_id } " )
476476
0 commit comments