aws-samples / aws-samples/amazon-textract-a2i-pdf

[Bug] - Multipage pdf scans result in breaking errors in analyzepdf

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
17
Forks
9
PR merge metrics
No merged PRs in 30d

Description

### How to replicate:
- Upload pdf into S3
- Step function never completes because callback token never completes
- Duplicate HumanLoopName as outline below and described in the cloudwatch logs.

### Stack Trace
```

[ERROR] InvalidParameterException: An error occurred (InvalidParameterException) when calling the AnalyzeDocument operation: HumanLoop '05d4e2d967f445aba29684f772fe3c4di1' already exists and is finished. To start a new HumanLoop, you can try your request again with a different HumanLoopName.Traceback (most recent call last):  File "/var/task/lambda_function.py", line 109, in lambda_handler    response, need_to_human_review = run_analyze_document(body)  File "/var/task/lambda_function.py", line 58, in run_analyze_document    response = client.analyze_document(  File "/var/runtime/botocore/client.py", line 386, in _api_call    return self._make_api_call(operation_name, kwargs)  File "/var/runtime/botocore/client.py", line 705, in _make_api_call    raise error_class(parsed_response, operation_name) | [ERROR] InvalidParameterException: An error occurred (InvalidParameterException) when calling the AnalyzeDocument operation: HumanLoop '05d4e2d967f445aba29684f772fe3c4di1' already exists and is finished. To start a new HumanLoop, you can try your request again with a different HumanLoopName. Traceback (most recent call last):   File "/var/task/lambda_function.py", line 109, in lambda_handler     response, need_to_human_review = run_analyze_document(body)   File "/var/task/lambda_function.py", line 58, in run_analyze_document     response = client.analyze_document(   File "/var/runtime/botocore/client.py", line 386, in _api_call     return self._make_api_call(operation_name, kwargs)   File "/var/runtime/botocore/client.py", line 705, in _make_api_call     raise error_class(parsed_response, operation_name)
-- | --

```

### where in the code it is happening:
Here: https://github.com/aws-samples/amazon-textract-a2i-pdf/blob/master/deploy_code/multipagepdfa2i_analyzepdf/lambda_function.py#L100

Contributor guide

Open the contributing guide

Research direction

Start at deploy_code/multipagepdfa2i_analyzepdf/lambda_function.py around line 100 and reproduce the multipage upload through S3. Trace how HumanLoopName is generated and how the Step Functions callback is completed; done means the multipage flow no longer fails with a duplicate finished HumanLoop and the callback completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.