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

EC2::DescribeVpcs uses incorrect MaxResults value by default #1016

Closed
ianbotsf opened this issue Aug 11, 2023 · 2 comments · Fixed by smithy-lang/smithy-kotlin#917
Closed
Assignees
Labels
bug This issue is a bug.

Comments

@ianbotsf
Copy link
Contributor

Describe the bug

Calling EC2's DescribeVpcs API without providing an explicit MaxResults causes an error about the parameter being invalid.

Expected behavior

The operation should succeed even when no parameters (including MaxResults) are passed.

Current behavior

The operation fails:

Exception in thread "main" aws.sdk.kotlin.services.ec2.model.Ec2Exception: Value ( 0 ) for parameter MaxResults is invalid. Expecting a value greater than or equal to 5.
	at aws.sdk.kotlin.services.ec2.transform.DescribeVpcsOperationDeserializerKt.throwDescribeVpcsError(DescribeVpcsOperationDeserializer.kt:64)
	at aws.sdk.kotlin.services.ec2.transform.DescribeVpcsOperationDeserializerKt.access$throwDescribeVpcsError(DescribeVpcsOperationDeserializer.kt:1)
	at aws.sdk.kotlin.services.ec2.transform.DescribeVpcsOperationDeserializerKt$throwDescribeVpcsError$1.invokeSuspend(DescribeVpcsOperationDeserializer.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at foo.ScratchKt.main(Scratch.kt:8)
	at foo.ScratchKt.main(Scratch.kt)

Steps to Reproduce

Execute this code:

fun main(): Unit = runBlocking {
    Ec2Client.fromEnvironment().use { ec2 ->
        ec2.describeVpcs().vpcs?.forEach { println(it) }
    }
}

Possible Solution

No response

Context

This same code runs successfully in 0.21.0-beta. Note that in that version, the body of the POST request is:

Action=DescribeVpcs&Version=2016-11-15

Note that no explicit MaxResults is specified in the body, which is correct.

In 0.29.1-beta, the body of the POST request is:

Action=DescribeVpcs&Version=2016-11-15&DryRun=false&MaxResults=0

Note that MaxResults=0 is included and is clearly erroneous.

AWS Kotlin SDK version used

0.29.1-beta

Platform (JVM/JS/Native)

OpenJDK Runtime Environment Corretto-17.0.8.7.1 (build 17.0.8+7-LTS)

Operating System and version

Amazon Linux 2

@ianbotsf ianbotsf added the bug This issue is a bug. label Aug 11, 2023
@ianbotsf ianbotsf self-assigned this Aug 11, 2023
@ianbotsf
Copy link
Contributor Author

The MaxResults field in the Smithy model:

"MaxResults": {
    "target": "com.amazonaws.ec2#DescribeVpcsMaxResults",
    "traits": {
        "smithy.api#clientOptional": {},
        "smithy.api#default": 0,
        "smithy.api#documentation": "(omitted)"
    }
}

The clientOptional annotation should supercede the default trait but currently the SDK is incorrectly serializing MaxResults=0 in the request.

@github-actions
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
Development

Successfully merging a pull request may close this issue.

1 participant