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

Sending a PutObject request with checksum fails if LogMode is set to LogRequestWithBody #1198

Closed
dayaffe opened this issue Jan 29, 2024 · 3 comments · Fixed by smithy-lang/smithy-kotlin#1035
Assignees
Labels
bug This issue is a bug.

Comments

@dayaffe
Copy link

dayaffe commented Jan 29, 2024

Describe the bug

Request succeeds with LogMode is set to LogRequest but fails when it is set to LogRequestWithBody.

Expected behavior

Request should succeed as it does when LogMode is set to LogRequest.

Current behavior

Error is thrown: Exception in thread "main" aws.sdk.kotlin.services.s3.model.S3Exception: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Steps to Reproduce

The following code fails:

fun main(): Unit = runBlocking {
    val client = S3Client.fromEnvironment {
        region = "us-west-2"
        logMode = LogMode.LogRequestWithBody
    }

    println(client.putObject {
        bucket = "dayaffe-testing"
        key = "my-metadata-key.txt"
        checksumAlgorithm = ChecksumAlgorithm.Crc32
        body = ByteStream.fromFile(File("non_sparse_file_small.dat"))
    })
}

Whereas the follow code succeeds:

fun main(): Unit = runBlocking {
    val client = S3Client.fromEnvironment {
        region = "us-west-2"
        logMode = LogMode.LogRequest
    }

    println(client.putObject {
        bucket = "dayaffe-testing"
        key = "my-metadata-key.txt"
        checksumAlgorithm = ChecksumAlgorithm.Crc32
        body = ByteStream.fromFile(File("non_sparse_file_small.dat"))
    })
}

Possible Solution

No response

Context

No response

AWS Kotlin SDK version used

Latest

Platform (JVM/JS/Native)

JVM

Operating System and version

Mac 14.2.1

@dayaffe dayaffe added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 29, 2024
@aajtodd aajtodd removed the needs-triage This issue or PR still needs to be triaged. label Jan 30, 2024
@aajtodd
Copy link
Collaborator

aajtodd commented Jan 30, 2024

I've been able to reproduce this. Interestingly it happens whether we request a flexible checksum or not. As long as we trigger chunked signing I'm seeing this.

Will work on a fix, thanks.

@lauzadis
Copy link
Member

I think it might be caused by this code segment in dumpRequest which changes the type of the body to ByteArray (no longer an AwsChunkedSource/AwsChunkedByteReadChannel)

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
3 participants