question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PoolManager.request() with invalid scheme produces KeyError

See original GitHub issue
>>> pm = urllib3.PoolManager
>>> pm.request('GET', 'FAKESCHEME://github.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/urllib3/request.py", line 69, in request
    **urlopen_kw)
  File "/usr/local/lib/python3.5/site-packages/urllib3/request.py", line 90, in request_encode_url
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.5/site-packages/urllib3/poolmanager.py", line 155, in urlopen
    conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
  File "/usr/local/lib/python3.5/site-packages/urllib3/poolmanager.py", line 128, in connection_from_host
    pool = self._new_pool(scheme, host, port)
  File "/usr/local/lib/python3.5/site-packages/urllib3/poolmanager.py", line 87, in _new_pool
    pool_cls = self.pool_classes_by_scheme[scheme]
KeyError: 'FAKESCHEME'

We should be fetching by that scheme more resiliently, and raising a more specific error message - possibly a LocationValueError?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
Lukasacommented, May 24, 2016

I’d be inclined to say that we should approach this with a YAGNI train of thought. I agree with @shazow that a custom exception makes sense, but it really only makes sense if we allow pluggable schemes. If we don’t ever do that, then I don’t think that a custom exception is warranted.

0reactions
sethmlarsoncommented, Jul 5, 2018

Probably. Will reopen if necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue24667 - Issue Tracker - Python.org
Looking further into this issue, OrderedDict.pop() using the key returned from the KeyError (using eval(str(error))) also yields a KeyError.
Read more >
python - LIME feature explaining produces invalid key error
I needed to first convert everything to a numpy array: class_names = X_train.columns X_train = X_train.to_numpy() X_test = X_test.to_numpy() ...
Read more >
T106212 KeyError in urllib3 since Python 3.5.0b3
It seems that recently the Python 3.6 builds fail due to urllib3 raising a KeyError (see https://travis-ci.org/xZise/pywikibot-core/builds/71550286#L7189):.
Read more >
Python Module Index - Requests Documentation
When you make a request, Requests makes educated guesses about the ... or if the response contains invalid JSON, attempting r.json() raises ...
Read more >
mozilla-central: changeset 607536 ...
PoolManager() + >>> r = http.request('GET', ... + +* Fix issue where URLs containing invalid characters within ``Url.auth`` would + raise an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found