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

Protocol test for : null values in unions #2180

Merged
merged 3 commits into from
Mar 18, 2024

Conversation

rcoh
Copy link
Contributor

@rcoh rcoh commented Mar 12, 2024

Background

Servers are allowed (but not recommended) to send "key": null for unset fields in unions. However, this behavior was not covered by protocol tests.

Testing

These tests were dry-run on the Rust SDK.

Links


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Servers are allowed (but not recommmended) to send `"key": null` for unset fields in unions. However, this behavior was not covered by protocol tests.

These tests were dry-run on the Rust SDK.
@rcoh rcoh requested a review from a team as a code owner March 12, 2024 18:51
@rcoh rcoh requested a review from kstich March 12, 2024 18:51
@@ -43,6 +43,7 @@ union MyUnion {
listValue: StringList,
mapValue: StringMap,
structureValue: GreetingStruct,
unitValue: Unit,
Copy link
Contributor

@kstich kstich Mar 13, 2024

Choose a reason for hiding this comment

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

Can the Unit target entry be separated out to its own test operation and case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed—I thought it was just an oversight that it was missing. Turns out this actually causes compilation failure in the Rust server codegen: smithy-lang/smithy-rs#2546

So we should definitely get a test with this at some point but it will probably break a few folks

github-merge-queue bot pushed a commit to smithy-lang/smithy-rs that referenced this pull request Mar 15, 2024
## Motivation and Context
- awslabs/aws-sdk-rust#1095

## Description
Update the JSON parser generator to allow for `null` to be set in
unions. Servers can send unions like this:
```json
{
  "AmazonElasticsearchParameters": null,
  "AmazonOpenSearchParameters": null,
  "AppFlowParameters": null,
  "AthenaParameters": null,
  "AuroraParameters": null,
  "AuroraPostgreSqlParameters": null,
  "AwsIotAnalyticsParameters": null,
  "BigQueryParameters": null,
  "DatabricksParameters": null,
  "Db2Parameters": null,
  "DenodoParameters": null,
  "DocumentDBParameters": null,
  "DremioParameters": null,
  "ExasolParameters": null,
  "GoogleAnalyticsParameters": null,
  "JiraParameters": null,
  "MariaDbParameters": null,
  "MongoAtlasParameters": null,
  "MongoDBParameters": null,
  "MySqlParameters": null,
  "OracleParameters": null,
  "PostgreSqlParameters": null,
  "PrestoParameters": null,
  "RdsParameters": null,
  "RedshiftParameters": null,
  "S3Parameters": {
    "IsUploaded": false,
    "ManifestFileLocation": {
      "Bucket": "deided-bucket.prod.us-east-1",
      "Key": "sales/manifest.json"
    },
    "RoleArn": null
  },
  "SalesforceParameters": null,
  "SapHanaParameters": null,
  "ServiceNowParameters": null,
  "SnowflakeParameters": null,
  "SparkParameters": null,
  "SqlServerParameters": null,
  "StarburstParameters": null,
  "TeradataParameters": null,
  "TrinoParameters": null,
  "TwitterParameters": null
}
```

This caused our parser to fail.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
- [x] New unit test
- [x] Dry run against new [smithy protocol
test](smithy-lang/smithy#2180)

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
@kstich kstich merged commit 1eb9965 into smithy-lang:main Mar 18, 2024
13 checks passed
@rcoh rcoh deleted the add-null-variant-test branch March 18, 2024 15:53
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