-
Notifications
You must be signed in to change notification settings - Fork 25
Update error messages for timeout errors #607
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
Update error messages for timeout errors #607
Conversation
|
Setting back to draft mode for now; I wanted to get this out there to confirm everyone is good with the two-pronged approach of both updating our CRT errors and having a default. I think the exception message should ultimately be something along the lines of |
packages/smithy-core/.changes/next-release/smithy-core-enhancement-20251124183509.json
Outdated
Show resolved
Hide resolved
| ) | ||
| except Exception as e: | ||
| if isinstance(e, self.transport.TIMEOUT_EXCEPTIONS): | ||
| error_msg = str(e) or type(e).__name__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like we're leaking a detail somewhere. Is this something coming from the CRT that's requiring us to pull the __name__ off the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more meant to target cases like aiohttp's total_timeout which only raises an empty asyncio.TimeoutError with no other context. I put a link to an example of this in the PR's description. It's just a way for us to make sure there's some string representation in an error where the string representation of it is otherwise empty.
Example from a Python REPL:
>>> str(TimeoutError())
''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from should give us the context (and the originating error). If they don't include anything, that's fine. By creating the chain, we can look to see what happened. Including {e} in the message to begin with is likely not necessary. That's an artifact of a time before we had better tracebacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A timeout error occurred. is probably sufficient in this case.
packages/smithy-http/.changes/next-release/smithy-http-enhancement-20251122132342.json
Outdated
Show resolved
Hide resolved
| except AwsCrtError as e: | ||
| if e.name in self._TIMEOUT_ERROR_NAMES: | ||
| raise _CRTTimeoutError() from e | ||
| raise _CRTTimeoutError(f"CRT {e.name}: {e.message}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we should be keeping the context with the from but we can include the message to make the immediate information clearer.
Co-authored-by: Nate Prewitt <[email protected]>
Description
This PR improves timeout error messages to provide more actionable information for debugging. Currently, timeout errors sometimes display messages like "Client timeout occurred: " with no additional context. This occurs when the error's string representation is an empty string.
For the CRT client, we updated _CRTTimeoutError to include the underlying AWS error name and message, changing errors from
Client timeout occurred:toCRT AWS_IO_SOCKET_TIMEOUT: socket operation timed out.For all clients, we now default to using the exception's class name when the string representation is empty. This can occur in aiohttp when the
totalattribute is set on theClientTimeoutclass, which will raise a TimeoutError with no additional info. This updates the same blank error message toA timeout error occurred..Test file:
timeout_exceptions_test.py
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.