You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Rekognition报InvalidParameterException异常排查请求

Troubleshooting InvalidParameterException in AWS Rekognition Node.js Code

Let’s walk through the most likely causes for this sudden error—since your code worked fine last month, the issue is probably a recent change to permissions, the image itself, or your configuration.

Possible Causes & Fixes

1. S3 Object/Bucket Permission Changes

Rekognition needs explicit permission to read the S3 object you’re passing in. Even if it worked before, permissions might have been modified recently:

  • Check IAM Role Permissions: Ensure the IAM role your Node.js app uses has the s3:GetObject permission for the mastekinnoations3learning bucket (and specifically the 1527119837382460.jpeg object). Double-check if any recent policy updates revoked this access.
  • Verify S3 Bucket Policy: Make sure the bucket policy doesn’t block Rekognition from accessing objects. You can test this quickly with the AWS CLI:
    aws rekognition detect-faces --image '{"S3Object": {"Bucket": "mastekinnoations3learning", "Name": "1527119837382460.jpeg"}}' --region us-west-2
    
    If the CLI throws the same error, the problem is likely permission-related, not your Node.js code.

2. Corrupted or Invalid Image File

It’s possible the image in S3 was overwritten, corrupted, or no longer meets Rekognition’s requirements:

  • Download and Validate the Image: Grab the image from S3 and confirm it opens properly in a viewer. Rekognition supports JPEG, PNG, and BMP files, with a maximum size of 15MB and minimum resolution of 8x8 pixels.
  • Check for Accidental Overwrites: Verify no recent updates replaced the original image with a broken or unsupported file.

3. Hardcoded Parameter Mistakes

Looking at your code, you’re importing s3BucketName and s3BucketKeyName from constants but then hardcoding the bucket and object name in the params object. This could lead to mismatches if the constants were updated but the hardcoded values weren’t:

  • Replace Hardcoded Values with Constants: Update your params to use the imported variables instead of static text:
    const params = { 
      Image: { 
        S3Object: { 
          Bucket: s3BucketName, 
          Name: s3BucketKeyName 
        } 
      } 
    };
    
    Also double-check if mastekinnoations3learning has a typo (e.g., maybe it should be masteinnovations3learning? The "noa" seems off).

4. AWS SDK or Region Mismatch

  • Update AWS SDK: Older versions of the AWS SDK might have compatibility issues with the Rekognition API. Run npm update aws-sdk to get the latest version and test again.
  • Confirm Region Configuration: Ensure your AWS config (in config.json) is set to us-west-2 (matching your S3 bucket’s region). Mismatched regions can sometimes trigger parameter errors even if the API call is technically valid.

Quick Test to Isolate the Issue

If you’re still stuck, try passing the image as a base64-encoded string instead of using S3 to rule out S3-specific problems. This will help confirm if the issue is with the image itself or the S3/Rekognition integration.

内容的提问来源于stack exchange,提问作者Sourabh Jain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:18:30