aws-samples / aws-samples/amazon-textract-code-samples

InvalidParameterException: Request has invalid parameters when using startDocumentAnalysis

Open
#58 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
449
Forks
262
PR merge metrics
No merged PRs in 30d

Description

**Description**
I'm encountering an InvalidParameterException: Request has invalid parameters error when attempting to use the startDocumentAnalysis method with AWS Textract in a Node.js application. The error occurs despite ensuring that all parameters are correctly specified.

**Environment**

- Node.js Version: 18.20.3
- AWS SDK Version: ^2.1548.0
- AWS Region: ap-south-1

**Here's the code I'm using**

```
public async startAnalyiseDocument(key: string) {
try {
const response = await this.textreact
.startDocumentAnalysis({
DocumentLocation: {
S3Object: {
Bucket: env.AWS_BUCKET_NAME as string,
Name: key as string,
},
},
FeatureTypes: [
"TABLES", "FORMS", "SIGNATURES"
],
NotificationChannel:{
RoleArn:env.AWS_ROLE_ARN as string,
SNSTopicArn: env.AWS_SNS_TOPIC_ARN as string,
},
})
.promise();
console.log('ERROR:',response.$response.error)
return response;
} catch (error) {
console.log("AWS_TXT:", error);
throw new Error(error);
}
}
```
**Error Details**

```
InvalidParameterException: Request has invalid parameters
at Request.extractError (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/protocol/json.js:80:27)
at Request.callListeners (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/Users/arunroot/Documents/mark93r/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/arunroot/Documents/mark93r/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/Users/arunroot/Documents/mark93/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
code: 'InvalidParameterException',
'[__type]': 'See error.__type for details.',
'[Message]': 'See error.Message for details.',
time: 2024-07-04T18:31:17.960Z,
requestId: 'd05e66d4-2b18-446e-938e-de9b56864963',
statusCode: 400,
retryable: false,
retryDelay: 79.76554747215391
}
```

**Additional Information**

- The `RoleArn` and `SNSTopicArn` are correctly specified and the IAM role has the necessary permissions.
- Before implementing `NotificationChannel` it was working fine.

Contributor guide

Open the contributing guide

Research direction

The relevant entry point is the startDocumentAnalysis call shown in the issue, especially the added NotificationChannel block. Start by checking the AWS SDK request parameters and the supplied role and topic values against the documented API requirements. Done means reproducing the request without InvalidParameterException and documenting the accepted configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, node.js
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.