Skip to content

Try different protocols against union in question#4333

Merged
vcjana merged 7 commits intomainfrom
unused-inner
Oct 10, 2025
Merged

Try different protocols against union in question#4333
vcjana merged 7 commits intomainfrom
unused-inner

Conversation

@vcjana
Copy link
Contributor

@vcjana vcjana commented Oct 6, 2025

Motivation and Context

Fixes unused variable warnings in RestXml/AwsQuery union serializers when variants contain empty structs. Discovered in S3Control's ObjectEncryptionFilter. Builds with -D warnings were failing.
Previous attempt fixed all serializers, but only RestXml/AwsQuery need it.
RestJson/CBOR always reference the inner variable.

Description

Modified QuerySerializerGenerator to prefix unused variables with underscore for empty struct variants:

  • Added isEmptyStruct() to detect empty structures
  • Use _inner for empty structs, inner for non-empty structs
  • No changes to JsonSerializerGenerator or CborSerializerGenerator (not affected)
Before:
ObjectEncryptionFilter::Sses3(inner) => { /* inner unused - warning */ }

After:
ObjectEncryptionFilter::Sses3(_inner) => { /* no warning */ }

Testing

Added tests for RestXml, AwsQuery, and RestJson (documents immunity)
Tests enforce -D warnings via clientIntegrationTest
Verified S3Control compiles cleanly with RUSTFLAGS="-D warnings"


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@vcjana vcjana requested review from a team as code owners October 6, 2025 17:36
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Changes to QuerySerializerGenerator look good.

For the changes to the tests (AwsQueryTest, RestJsonTest, and RestXmlTest), we should keep the existing ones untouched and add new tests with separate test models. Feel free to rename SSES3Filter in test models to something that sounds like one-off, test-specific; it's totally fine if we don't preserve type name from s3control at this point.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Oct 7, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Would like to rename test models a bit and simplify them. Once that's done, we're good to go!

}

@Test
fun `union with empty struct always uses inner variable`() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test name 👍

}

@Test
fun `union with empty struct generates warning-free code`() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test name 👍

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

ysaito1001 and others added 7 commits October 9, 2025 16:02
…ith empty structs

- Add isEmptyStruct() helper to detect empty struct shapes
- Use _inner for empty structs to avoid unused variable warnings
- Use inner for non-empty structs where variable is used
- Add comprehensive tests for RestXml, AwsQuery, and RestJson protocols
- Tests enforce -D warnings via clientIntegrationTest
Prefix writer with underscore when union contains only empty structs
When building tests, discovered that serializeUnion was using incorrect
variable name for empty struct members. The pattern match correctly used
'_inner' but serializeMember was called with 'inner', causing compilation
errors. Fixed by passing the correct variable name based on whether the
struct is empty.
- Rename modelWithEmptyStruct to inputUnionWithEmptyStructure
- Remove output parameter and TestOutput structure
- Focus tests on input serialization only
@github-actions
Copy link

github-actions bot commented Oct 9, 2025

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@vcjana vcjana merged commit d4c11dd into main Oct 10, 2025
50 checks passed
@vcjana vcjana deleted the unused-inner branch October 10, 2025 00:33
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

Successfully merging this pull request may close these issues.

2 participants