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

Unable to send empty map value in request #332

Closed
j0hnsmith opened this issue Jul 1, 2019 · 4 comments · Fixed by #337 or #344
Closed

Unable to send empty map value in request #332

j0hnsmith opened this issue Jul 1, 2019 · 4 comments · Fixed by #337 or #344
Assignees
Labels
bug This issue is a bug. refactor

Comments

@j0hnsmith
Copy link

j0hnsmith commented Jul 1, 2019

Version of AWS SDK for Go?

v0.9.0

Version of Go (go version)?

all

What issue did you see?

In the api lex api, sending an empty map for the key sessionAttributes: {} deletes existing session attributes however omitting the key keeps the existing ones. It's not possible to delete attributes as no distinction, in the current implementation, is made between a nil map and an empty one.

if len(s.SessionAttributes) > 0 {

Steps to reproduce

  • make first request with session attributes
  • response includes session attributes as expected
  • make second request with empty session attributes map
  • response includes session attributes as set by first request, they should have been removed

https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html

@jasdel
Copy link
Contributor

jasdel commented Jul 1, 2019

Thanks for reporting this issue @j0hnsmith. This looks to be a issue with the SDK's marshaling code generator not distinguishing between empty and nil. This behavior is probably similar with slices as well as maps.

We need to investigate this behavior, I would think sending empty list/map would be the correct behavior when empty.

@jasdel jasdel added bug This issue is a bug. refactor labels Jul 1, 2019
@jasdel jasdel changed the title Lex: can't delete session attributes Unable to send empty map value in request Jul 1, 2019
@jasdel
Copy link
Contributor

jasdel commented Jul 4, 2019

The code generation that drives the len(v) > 0 check is in private/model/api/shape_marshal.go

@jasdel jasdel assigned jasdel and skotambkar and unassigned jasdel Jul 4, 2019
skotambkar pushed a commit to skotambkar/aws-sdk-go-v2 that referenced this issue Jul 10, 2019
jasdel pushed a commit that referenced this issue Jul 11, 2019
#337)

Updated shape marshal model to handle the empty map vs nil map behavior.
Adding a test case to assert behavior when a user sends an empty map vs nil map.

Fix #332
@jasdel
Copy link
Contributor

jasdel commented Jul 11, 2019

Thanks for reporting this issue @j0hnsmith. We've merged in a fix that addresses this bug. You should now be able to send empty maps and lists with the V2 SDK.

@j0hnsmith
Copy link
Author

Great work and so quick, thanks, I'll try it out tomorrow.

jasdel added a commit to jasdel/aws-sdk-go-v2 that referenced this issue Jul 24, 2019
Services
===
* Synced the V2 SDK with latest AWS service API definitions.
* Fixes [aws#341](aws#341)
* Fixes [aws#342](aws#342)

SDK Breaking Changes
===
* `aws`: Add default HTTP client instead of http.DefaultClient/Transport ([aws#315](aws#315))
  * Adds a new BuildableHTTPClient type to the SDK's aws package. The type uses the builder pattern with immutable changes. Modifications to the buildable client create copies of the client.  Adds a HTTPClient interface to the aws package that the SDK will use as an abstraction over the specific HTTP client implementation. The SDK will default to the BuildableHTTPClient, but a *http.Client can be also provided for custom configuration.  When the SDK's aws.Config.HTTPClient value is a BuildableHTTPClient the SDK will be able to use API client specific request timeout options.
  * Fixes [aws#279](aws#279)
  * Fixes [aws#269](aws#269)

SDK Enhancements
===
* `service/s3/s3manager`: Update S3 Upload Multipart location ([aws#324](aws#324))
  * Updates the Location returned value of S3 Upload's Multipart UploadOutput type to be consistent with single part upload URL. This update also brings the multipart upload Location inline with the S3 object URLs created by the SDK.
  * Fixes [aws#323](aws#323)
  * V2 Port [aws/aws-sdk-go#2453](aws/aws-sdk-go#2453)

SDK Bugs
===
* `private/model`: Handles empty map vs unset map behavior in send request ([aws#337](aws#337))
  * Updated shape marshal model to handle the empty map vs nil map behavior. Adding a test case to assert behavior when a user sends an empty map vs nil map.
  * Fix [aws#332](aws#332)
* `service/rds`: Fix presign URL for same region ([aws#331](aws#331))
  * Fixes RDS no-autopresign URL for same region issue for aws-sdk-go-v2. Solves the issue by making sure that the presigned URLs are not created, when the source and destination regions are the same. Added and updated the tests accordingly.
  * Fix [aws#271](aws#271)
* `private/protocola/json/jsonutil`: Fix Unmarshal map[string]bool ([aws#320](aws#320))
  * Fixes the JSON unmarshaling of maps of bools. The unmarshal case was missing the condition for bool value, in addition the bool pointer.
  * Fix [aws#319](aws#319)
jasdel added a commit that referenced this issue Jul 25, 2019
Services
===
* Synced the V2 SDK with latest AWS service API definitions.
* Fixes [#341](#341)
* Fixes [#342](#342)

SDK Breaking Changes
===
* `aws`: Add default HTTP client instead of http.DefaultClient/Transport ([#315](#315))
  * Adds a new BuildableHTTPClient type to the SDK's aws package. The type uses the builder pattern with immutable changes. Modifications to the buildable client create copies of the client.  Adds a HTTPClient interface to the aws package that the SDK will use as an abstraction over the specific HTTP client implementation. The SDK will default to the BuildableHTTPClient, but a *http.Client can be also provided for custom configuration.  When the SDK's aws.Config.HTTPClient value is a BuildableHTTPClient the SDK will be able to use API client specific request timeout options.
  * Fixes [#279](#279)
  * Fixes [#269](#269)

SDK Enhancements
===
* `service/s3/s3manager`: Update S3 Upload Multipart location ([#324](#324))
  * Updates the Location returned value of S3 Upload's Multipart UploadOutput type to be consistent with single part upload URL. This update also brings the multipart upload Location inline with the S3 object URLs created by the SDK.
  * Fixes [#323](#323)
  * V2 Port [aws/aws-sdk-go#2453](aws/aws-sdk-go#2453)

SDK Bugs
===
* `private/model`: Handles empty map vs unset map behavior in send request ([#337](#337))
  * Updated shape marshal model to handle the empty map vs nil map behavior. Adding a test case to assert behavior when a user sends an empty map vs nil map.
  * Fix [#332](#332)
* `service/rds`: Fix presign URL for same region ([#331](#331))
  * Fixes RDS no-autopresign URL for same region issue for aws-sdk-go-v2. Solves the issue by making sure that the presigned URLs are not created, when the source and destination regions are the same. Added and updated the tests accordingly.
  * Fix [#271](#271)
* `private/protocola/json/jsonutil`: Fix Unmarshal map[string]bool ([#320](#320))
  * Fixes the JSON unmarshaling of maps of bools. The unmarshal case was missing the condition for bool value, in addition the bool pointer.
  * Fix [#319](#319)
skotambkar added a commit to skotambkar/aws-sdk-go-v2 that referenced this issue Aug 19, 2019
aws#337)

Updated shape marshal model to handle the empty map vs nil map behavior.
Adding a test case to assert behavior when a user sends an empty map vs nil map.

Fix aws#332
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. refactor
Projects
None yet
3 participants