Skip to content

fix: wrap urllib3 DecodeError and TimeoutError exceptions in requests API#114

Open
label-hook[bot] wants to merge 1784 commits into
mainfrom
phoenix/issue-113
Open

fix: wrap urllib3 DecodeError and TimeoutError exceptions in requests API#114
label-hook[bot] wants to merge 1784 commits into
mainfrom
phoenix/issue-113

Conversation

@label-hook

@label-hook label-hook Bot commented Apr 19, 2026

Copy link
Copy Markdown

Summary

This PR addresses issue #113 by preventing urllib3 exceptions from leaking through the requests API. Previously, urllib3.exceptions.DecodeError and urllib3.exceptions.TimeoutError could bubble up to users, requiring them to catch both requests and urllib3 exceptions.

Changes

  • Added DecodeError exception class in requests/exceptions.py that inherits from RequestException
  • Modified exception handling in requests/adapters.py to catch urllib3 DecodeError and TimeoutError exceptions and wrap them in appropriate requests exception types
  • Improved API consistency by ensuring all exceptions raised by requests are part of the requests exception hierarchy

This change maintains backward compatibility while providing a cleaner, more consistent exception interface for users of the requests library.

Testing

The implementation was tested to ensure:

  • urllib3 DecodeError exceptions are now caught and wrapped as requests DecodeError
  • urllib3 TimeoutError exceptions are properly handled within the existing requests timeout exception framework
  • No new test failures were introduced to the baseline test suite
  • Exception wrapping maintains original error information and context

Closes #113


Closes #113

sigmavirus24 and others added 30 commits November 7, 2014 14:18
Cap the redirect_cache size to prevent memory abuse
Ensure pos is set to None when the body is not a file
so that HTTPDigestAuth detects the type of the body correctly.
Fix HTTPDigestAuth not to treat non-file as a file
Close sessions created in the functional API
Add overriding Content-Length
Note about read timeout errors and max_retries
Add DeprecationWarnings to inform users of plans
Addresses the LocationParseError but not the DecodeError from
kennethreitz#1572. When running
test_requests.py, I got an error in test_session_pickling which resulted
in a TypeError. I'm not sure of the reason for the TypeError but I have
commented out that test.
so sections can be linked from other projects using Intersphinx
RecentlyUsedContainers are threadsafe so they require a lock and as such
cannot be serialized with pickle directly. To handle it, we need to
convert it to a dictionary first and then back when deserializing.

Fixes psf#2345
url was already parsed, don't urlparse twice
Docs: Add more section labels for referencing
Properly serialize RecentlyUsedContainers for cache
Enable GitHub syntax highlighting on README
radarhere and others added 27 commits May 21, 2015 10:25
fix contextlib.closing bug for sessions where content is not consumed…
Allows for sections to be linked from other projects using Intersphinx.
Docs: Add more section labels for referencing
Avoid double releasing chunked upload connections
It seems convenient to include the URL in the error message in case you
get an unexpected error.

E.g.:

    In [1]: import requests

    In [2]: resp = requests.get('http://www.google.com/eofdfdfdfdfd')

    In [3]: resp
    Out[3]: <Response [404]>

    In [4]: resp.raise_for_status()
    ---------------------------------------------------------------------------
    HTTPError                                 Traceback (most recent call last)
    <ipython-input-4-00e7077cfb5b> in <module>()
    ----> 1 resp.raise_for_status()

    /Users/marca/dev/git-repos/requests/requests/models.py in raise_for_status(self)
        835
        836         if http_error_msg:
    --> 837             raise HTTPError(http_error_msg, response=self)
        838
        839     def close(self):

    HTTPError: 404 Client Error: Not Found for url: http://www.google.com/eofdfdfdfdfd
Display URL as part of HTTP error messages
If the netrc file exists but cannot be parsed or read, get_netrc_auth
silently fails.

Add a new argument `ignore_errors` which when set to False will cause
any parse/permission errors to be raised to the caller.  The default
value is True, which means the default behavior is unchanged.

Fixes psf#2654

Change-Id: I7436aaaf593178673ab84fd9e7ab4bcb0e3fe75e
Change-Id: Ib82c7c614edafc15e5db858d9c1b9a73aebd8a95
Allow get_netrc_auth to raise parse/permission errors to caller
Only pass useful timeouts to _get_conn
- Test for NotImplemented in __eq__
- Adds test for copy()
- Adds test for __repr__()
Adds extra tests for CaseInsensitiveDict
Previously this section prefaced an example with:

    For example, we didn't specify our content-type

But, the actual example set a custom user-agent header on the request. This
changes it to say "user-agent" instead which matches the given example.
Fix quickstart "Custom Headers" example intro
@label-hook label-hook Bot added the ai:review Phoenix AI: PR ready for review label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:review Phoenix AI: PR ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SWE-bench] psf__requests-2674