cdk-constructs icon indicating copy to clipboard operation
cdk-constructs copied to clipboard

fix(dynamodb-seeder): Correct S3 file stream handling with transformToString

Open cmcneilniu opened this issue 7 months ago • 0 comments

Resolve the issue: https://github.com/cloudcomponents/cdk-constructs/issues/214

Summary

Fixes JSON parsing errors in the DynamoDB seeder by:

  • Replacing body.toString() with transformToString('utf-8') for proper S3 stream handling

Changes

  • Updated getSeedsFromS3 to use AWS SDK v3's transformToString:
    • Ensures correct UTF-8 decoding of S3 files
    • Prevents malformed JSON errors from stream corruption

Impact

  • Fixes Unexpected token errors when parsing seed files
  • Maintains backward compatibility with existing S3 buckets/keys

Error Context

Fixes cases where body.toString() corrupted S3 files, causing errors like: Unexpected token 'o' in JSON at position 1

cmcneilniu avatar May 01 '25 00:05 cmcneilniu