Skip to content

DynamoDBEvent.Decoder doesn't properly handle binary encoded as a base64encoded string #60

Open
@gregggreg

Description

@gregggreg

Expected behavior

binary values in a DynamoDBEvent, coming in as base64 encoded strings, should get decoded properly when using the DynamoDBEvent.Decoder

Actual behavior

If you try to use DynamoDBEvent.Decoder on binary values, it throws an error saying it is expecting the value to be a string

Steps to reproduce

  1. Use DynamoDBEvent.Decoder to decode a class with a binary attribute coming from a DynamoDBEvent.

If possible, minimal yet complete reproducer code (or URL to code)

func handle(_ input: DynamoDBEvent, context: LambdaContext) async throws -> Response {
    for record in input.records {
        guard let newImage = record.change.newImage else {
            context.logger.error("No new image in record")
            continue
        }
        let update = try DynamoDBEvent.Decoder().decode(MyModel.self, from: newImage)
    }
}

SwiftAWSLambdaRuntime version/commit hash

version 0.4.0

Swift & OS version (output of swift --version && uname -a)

Target: arm64-apple-macosx14.0
Darwin max.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 x86_64 i386 MacBookPro18,2 Darwin

I have a fix for this which I can provide as a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions