Skip to content

No error throw if not credential are provided. SDK validation previous to send request. #6

@danieleiya

Description

@danieleiya

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 json

As 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'
        } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions