-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
SESV2 ListContacts breaks with "Content-Length not given and Transfer-Encoding is not `chunked'" #2836
Comments
Thanks for the detailed report. I agree it's broken - and you are possibly the first one to find it (many customers still use SES v1). We deliberately blocked Content-Length for GET methods because it is ambiguous / un-defined / not intended and is actually not recommended in our AWS API standards. But alas, here we are, and there are some teams/services where this slipped in, and even did so prior to that guidance. Let me follow up with the team to see if we should write in a hack or if we can get the SES team to fix their modeling. We are generating a default body of In the mean time, you can certainly monkey patch |
@mullermp Thanks for following up so quickly! BTW, I'm not yet following "We are generating a default body of In my original code, I was also passing a If I update the script as follows (looking more like the list_contacts API documentation)... #!/usr/bin/env ruby
require 'aws-sdk-sesv2'
options = {
contact_list_name: "TestList",
filter: {
filtered_status: "OPT_IN",
topic_filter: {
topic_name: "TestTopic",
use_default_if_preference_unavailable: true,
},
},
page_size: 1,
next_token: "NextToken",
}
Aws::SESV2::Client.new.list_contacts(options).each do |r|
r.contacts.each {|c| puts c.to_s}
end ...and hack this into def send_request_with_body_stream(sock, ver, path, f)
puts "PATH: #{path}\nBODY:\n#{f.string}" ...the script produces the following output before the stack trace:
|
The Ruby SDK is placing Filter in the body correctly because that's what the model says to do. But it is a GET operation with a modeled body, which is incorrect. The Ruby SDK is correctly inspecting the model and seeing at least one member (Filter) and generating a default body I talked with other teams on this and apparently this is a known issue. The operation is just broken for Java SDK, .NET, and others. After talking with our leadership here, I am going to re-raise this to the SES team with high severity. The service model change is not trivial. To unblock you, I recommend monkey patching |
That makes perfect sense now, thanks! And thanks for taking the issue up the chain. |
Has there been any progress on this? This is quite a big deal if anyone is thinking about using the SDK for synching a contact list (ie remove the deleted contacts from a list would require fetching the contacts within a list first). Are there any other ways for synching a contact list? Otherwise, I guess the only option is to write this method outside of the SDK for now using HTTParty or Faraday directly. |
Checking the internal ticket I created, it looks like estimated fix is this month some time. I'll check in and see the progress. In the mean time, you can use the monkey patch method above. |
@mullermp thanks for the explanation, I just ran into this. Any news? |
None yet, annoyingly. I am going to make noise on this one, because it's been lingering again for too long. |
This looks to be fixed as of today. Please give it a try and let me know if there are any issues. d64f04b#diff-5c4ea219c21cf488f5de98b490f875ad38db14867dcad78c54539a7328b54b2cR7 |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
The
ListContacts
SESV2 API call uses the GET method, but includes a JSON body. However,Seahorse::Client::Plugins::ContentLength::Handler.call()
doesn't set theContent-Length
HTTP header for GET requests. This causes the resulting HTTP request to fail with:Expected Behavior
Calling
Aws::SESV2::Client.new.list_contacts
should return a list of contacts from a valid SES contact list.If the method worked as expected, the Reproduction Steps script would instead fail with:
List with name: TestList doesn't exist. (Aws::SESV2::Errors::NotFoundException)
.Current Behavior
Calling
Aws::SESV2::Client.new.list_contacts
in the Reproduction Steps script creates a{}
request body, producing the stack trace below. An existing SES contact list and a filter spec (which would produce more JSON body content) isn't necessary.The short version:
The full version:
Reproduction Steps
Possible Solution
It would seem worth updating
Seahorse::Client::Plugins::ContentLength::Handler.call()
to always setContent-Length
whenbody.respond_to?(:size) && body.size != 0
is true.Depending on the complexity of the proper solution, I'm happy to file a PR myself. Either way, I'm in no rush, as I have a hacky but effective workaround for my personal project.
Then again, as noted in Additional Information/Context, having a body in GET request is an ambiguous use case. It would seem "more correct" to update the API to use URL params (which would require some massaging) or the POST method instead.
However, I'm sure there are many clients of the published API, which would render updating the API spec impractical (before the next major version, anyway). Also, I tried searching several times for this error before diving in, and I seem to be the only person in the world calling ListContacts via the Ruby SDK right now.
Additional Information/Context
The ListContacts API call documentation shows the
GET
method with a JSON body:Here's the current implementation of
Seahorse::Client::Plugins::ContentLength::Handler.call()
fromaws-sdk-core-3.170.1/lib/seahorse/client/plugins/content_length.rb
, which doesn't set theContent-Length
HTTP header for GET requests:aws-sdk-ruby/gems/aws-sdk-core/lib/seahorse/client/plugins/content_length.rb
Lines 9 to 26 in cfe7ba3
I was able to instrument this method to see what was happening, and hack it to send a successful
ListContacts
request (by commenting out the!METHODS_WITHOUT_BODY
expression):I would see this before the successful call in my actual code, which included a
Filter
:FWIW, including a body in a GET request is apparently an ambiguous use case, per https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET:
Further discussion:
The current API spec in this repo:
aws-sdk-ruby/apis/sesv2/2019-09-27/api-2.json
Lines 643 to 656 in 049b16e
Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version
aws-sdk-sesv2 (1.32.0), aws-sdk-core (3.170.1)
Environment details (Version of Ruby, OS environment)
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22], macOS 13.2.1
The text was updated successfully, but these errors were encountered: