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

InvalidParameterException: Request has invalid parameters when using startDocumentAnalysis

未关闭
#58 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Jupyter Notebook
星标
449
派生
262
PR 合并指标
30 天内没有已合并 PR

描述

**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.

贡献指南

打开贡献指南

调研方向

相关入口点是 issue 中显示的 startDocumentAnalysis 调用,尤其是新增的 NotificationChannel 块。首先检查 AWS SDK 请求参数以及提供的 role 和 topic 值是否符合文档所述的 API 要求。在不产生 InvalidParameterException 的情况下复现该请求,并记录可接受的配置,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
aws, node.js
领域
backend, cloud
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
28/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。