Kong / Kong/unirest-python

HTTP Basic Auth - sending username but no password triggers exception

Open
#38 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
434
Forks
103
PR merge metrics
No merged PRs in 30d

Description

Reported on our repo here: https://github.com/Staffjoy/suite/issues/3

We send an API key as an HTTP basic username without a password, e.g. `curl --user API_KEY: http://app.local`. This appears to throw the following error on python 2.7 with unirest 1.1.7:

```
Traceback (most recent call last):
File "/opt/python/2.7.12/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/opt/python/2.7.12/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/travis/virtualenv/python2.7.12/lib/python2.7/site-packages/unirest/__init__.py", line 82, in __request
encoded_string = base64.b64encode(user + ':' + password)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The traceback points to unirest/__init__.py, in __request where HTTP Basic Auth is assembled; start there and reproduce the API-key-only request described in the issue. Done means a username with no password no longer raises the reported TypeError; add or run coverage for that request if the repository provides it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.