Skip to content

Conversation

@richardwang1124
Copy link
Contributor

Fixes #3350.


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

  1. To make sure we include your contribution in the release notes, please make sure to add description entry for your changes in the "unreleased changes" section of the CHANGELOG.md file (at corresponding gem). For the description entry, please make sure it lives in one line and starts with Feature or Issue in the correct format.

  2. For generated code changes, please checkout below instructions first:
    https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md

Thank you for your contribution!

@aws aws deleted a comment from github-actions bot Jan 29, 2026
@status_code = status_code
@body = body
msg = "HTTP #{status_code}"
msg += ": #{body[0..200]}" if body && !body.empty?
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume the ..200 is to truncate large bodies/limit the size of the message?

If so, may want to use a constant for 200 - otherwise at a quick glance it looks like it matches the 200 response code.

I can't remember do we do truncation like this anywhere else? We might want to make it clear when the body is truncated (something like "..." or "[truncated]") - otherwise, it might look like an incomplete response from the service was part of the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I added it in case error messages got really long but I don't think the truncation is necessary. I'll remove it.

set_authorization_token(request)
response = connection.request(request)
raise Non200Response unless response.code.to_i == 200
raise Non200Response.new(response.code.to_i, response.body) unless response.code.to_i == 200
Copy link
Contributor

Choose a reason for hiding this comment

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

just to double check - .body will always give a string and not an IO right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I believe it will always return a string. From https://ruby-doc.org/3.3.2/stdlibs/net/Net/HTTP.html regarding Net::HTTP.get:

Sends a GET request and returns the HTTP response body as a string.

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.

Improve error message when ECS credentials endpoint returns HTTP 429 (rate limited)

2 participants