soto-project / soto

Swift SDK for AWS that works on Linux, macOS and iOS
https://soto.codes
Apache License 2.0
867 stars 81 forks source link

Decoding failure #720

Open Buratti opened 1 week ago

Buratti commented 1 week ago

Describe the bug Lambda.UpdateFunctionConfiguration fails when it comes to decode the response. The function configuration is updated correctly.

dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "LastUpdateStatusReasonCode", intValue: nil)], debugDescription: "Cannot initialize LastUpdateStatusReasonCode from invalid String value Creating", underlyingError: nil))

To Reproduce Steps to reproduce the behavior:

let httpClient = HTTPClient(eventLoopGroupProvider: .singleton)
let awsClient = AWSClient(httpClientProvider: .createNew)

defer {
    try? awsClient.syncShutdown()
    try? httpClient.syncShutdown()
}

let lambda = Lambda(client: awsClient)
let request = Lambda.UpdateFunctionConfigurationRequest(functionName: "")
_ = try await lambda.updateFunctionConfiguration(request)

Expected behavior Should not fail

Setup (please complete the following information):

Additional context Tested in eu-central-1, should not be relevant though.

0xTim commented 1 week ago

@Buratti are you able to breakpoint inside the HTTPClient call and get the JSON body returned? Because Creating should not be being returned as the reason code - https://docs.aws.amazon.com/lambda/latest/api/API_UpdateFunctionConfiguration.html#lambda-UpdateFunctionConfiguration-response-LastUpdateStatusReasonCode

Buratti commented 1 week ago

Sure! I'll need an hour though, I'm OOO right now. What I can tell you right now is that the I have tried the same invocation using aws-cli earlier, and it also returned Creating. I'll paste the response received inside the HTTPClient in a new comment later!

adam-fowler commented 1 week ago

@Buratti would you be able to try this with the 7.0.0-rc version

Actually don't bother Creating as a case doesn't exist in 7 either. I may have to patch the enums

Buratti commented 1 week ago

Breakpointing here the response does indeed return a "Creating" string.

This looks like a bug on AWS side, I couldn't find any reference of Creating either and GetFunctionConfiguration does not even return it. Creating also looks like an unexpected case for a function that has been "created" and updated for over two years.

adam-fowler commented 1 week ago

It is a pain when the model files amazon provide are not up to date with the actual reality. I have add a patch to code generator and have run it on the models. You can test the aws-update-models branch, but that'll require you to upgrade to 7.0 code base. As long as you are only using Swift concurrency that shouldn't be too hard.

I'm hoping to do v7 release in the very near future

0xTim commented 1 week ago

Looks like they've just updated them (it's in #717)

adam-fowler commented 1 week ago

Looks like they've just updated them (it's in #717)

That's my patch

0xTim commented 1 week ago

Oh lol I misread the PR 😅

Buratti commented 1 week ago

IMHO I would argue that this is a bug, not a "synchronization" problem with their models. Otherwise I couldn't understand why the difference behavior between GetFunctionConfiguration and UpdateFunctionConfiguration. I've open a case on AWS Support and update this issue with their answer.

This isn't a big issue for us right now, it's a very simple helper script and I can work around it ignoring the DecodingError, not a big deal.

I will try the patch, migrating to soto 7 was very high on my priority list anyway (thanks for adding tracing support, loved seeing it).

adam-fowler commented 1 week ago

IMHO I would argue that this is a bug, not a "synchronization" problem with their models.

You are probably correct, but AWS aren't always fast to move so I tend to patch models until they are fixed.

Please keep us updated on their response thanks