splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

Splunk _handle_auth_error masks authentication errors as login errors

Open SyraD opened this issue 8 years ago • 3 comments

@contextmanager
def _handle_auth_error(msg):
    """Handle reraising HTTP authentication errors as something clearer.

    If an ``HTTPError`` is raised with status 401 (access denied) in
    the body of this context manager, reraise it as an
    ``AuthenticationError`` instead, with *msg* as its message.

    This function adds no round trips to the server.

    :param msg: The message to be raised in ``AuthenticationError``.
    :type msg: ``str``

    **Example**::

        with _handle_auth_error("Your login failed."):
             ... # make an HTTP request
    """
    try:
        yield
    except HTTPError as he:
        if he.status == 401:
            raise AuthenticationError(msg, he)
        else:
            raise

SyraD avatar Nov 19 '18 01:11 SyraD

@SyraD - thanks for the bug report! We're now tracking this internally. We appreciate your help with identifying and fixing these issues.

tdhellmann avatar Nov 19 '18 15:11 tdhellmann

@SyraD we have updated the error message. The change will be available in the next release. Refer the change

ashah-splunk avatar Apr 14 '22 11:04 ashah-splunk

@SyraD we would request you to use the latest SDK release with the change implemented. Thanks!

ashah-splunk avatar Jul 12 '22 12:07 ashah-splunk