Skip to content

Improve error message for providers#3352

Merged
richardwang1124 merged 3 commits intoversion-3from
feature/improve-credentials-error
Feb 2, 2026
Merged

Improve error message for providers#3352
richardwang1124 merged 3 commits intoversion-3from
feature/improve-credentials-error

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.

@richardwang1124 richardwang1124 merged commit f078ff9 into version-3 Feb 2, 2026
28 checks passed
@richardwang1124 richardwang1124 deleted the feature/improve-credentials-error branch February 2, 2026 16:29
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