disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/
Other
343 stars 69 forks source link

Operation `AmazonS3.ListBuckets` fails #1512

Open kkrs opened 4 months ago

kkrs commented 4 months ago

Running

object S3ListFail extends IOApp.Simple {
  val loggingHttpClient: Resource[IO, Client[IO]] =
    for
      cl <- EmberClientBuilder.default[IO].build
      reqLogger  = RequestLogger(logHeaders = true, logBody = true, logAction = Some(IO.println(_)))
      respLogger = ResponseLogger(logHeaders = true, logBody = true, logAction = Some(IO.println(_)))
      logging    = reqLogger(respLogger(cl))
    yield logging

  val awsEnv =
    for
      cl  <- loggingHttpClient
      env <- AwsEnvironment.default(cl, AwsRegion.US_WEST_1)
    yield env

  def run: IO[Unit] =
    awsEnv.flatMap(env => AwsClient(S3, env))
      .use {
        case s3 =>
          s3.listBuckets()
      }
      .map(IO.println(_))
}

begets

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
HTTP/1.1 GET http://169.254.169.254/latest/meta-data/iam/security-credentials/ Headers(Accept: text/*) body=""
HTTP/1.1 GET https://s3.us-west-1.amazonaws.com/ Headers(Authorization: <REDACTED>, host: s3.us-west-1.amazonaws.com, X-Amz-Date: 20240507T224635Z, X-Amz-Target: AmazonS3.ListBuckets) body=""
HTTP/1.1 400 Bad Request Headers(x-amz-request-id: BPHJSED8CXV329FZ, x-amz-id-2: Z9h3qA9tYtylgMvmCUi7FOUwaAIbNqQjnI906TRpl3WZcrnIXSnBEYYqeSj9mgDLRHdHsyn9rL4=, Content-Type: application/xml, Transfer-Encoding: chunked, Date: Tue, 07 May 2024 22:46:34 GMT, Server: AmazonS3, Connection: close) body="<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidRequest</Code><Message>Missing required header for this request: x-amz-content-sha256</Message><RequestId>BPHJSED8CXV329FZ</RequestId><HostId>Z9h3qA9tYtylgMvmCUi7FOUwaAIbNqQjnI906TRpl3WZcrnIXSnBEYYqeSj9mgDLRHdHsyn9rL4=</HostId></Error>"
PayloadError(.ErrorResponse, expected = , message=Could not decode failed node)
daddykotex commented 4 months ago

Before I give you any explanation, thanks for reporting the issue and trying Smithy4s.

S3 is one of those services that uses the @streaming trait that's not supported right now. On the other hand, the ListBucket operation that you're trying to use right now should work.

There are some changes in 1496 that would make this work. I'll try to open a separate PR that enable ListBuckets in 0.18 by only tweaking the AWSSigning process.

kkrs commented 4 months ago

@daddykotex - isn't super urgent. If #1496 will merge soon and making a separate PR is a lot of work, this can wait. Let me know and I'll link this issue to that PR.