-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
We got an error in our pipeline , the error throw is "simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" , this error is raised here:
#src/facturama/facturama/__init__.py
elif body.status_code == 401:
raise AuthenticationError(body.json()) //here fails to parse the jsonAs the body response is not a json then a JSONDecodeError is thrown.
It would be really usefull if you add a validation than inspect credentials are not NONE (or falsy), the most common case is when environment or settings are not correctly set up (for instance in a new deployment), or even in a integration phase.
The place were the validation could be implemented is:
@classmethod
def aut_api(cls):
_username, _password = _credentials # here check that both username and password are not false or explicity to None and ''
if not _username or not _password:
raise FacturamaError('username or password are not set') #the custom error and message that you consider useful
cls._headers = {
'Authorization': 'Basic %s' % (base64.b64encode(
('{}:{}'.format(_username, _password)).encode('utf-8'))).decode('ascii'),
'content-type': 'application/json'
} Deathpandk and ricardoventagium
Metadata
Metadata
Assignees
Labels
No labels