Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gregggreg opened this issue Aug 12, 2024 · 2 comments

Comments

@gregggreg
Copy link

gregggreg commented Aug 12, 2024

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

@gregggreg
Copy link
Author

#61

@sebsto
Copy link
Contributor

sebsto commented Nov 7, 2024

Thank you @gregggreg for proposing a PR for that. Can you add a unit test to cover the change you proposed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants