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

splunklib.binding.HTTPlib.request improper exception handling.

Open joroger opened this issue 1 year ago • 0 comments

Each time an HTTP request is made, splunklib checks the if the response code 400 or greater (line 1345). If the response code is 400 <= then an exception is raised by calling the HTTPError(). HTTPError has no return, so a generic Python error message of BaseException.with_traceback() takes exactly one argument (0 given) Testing has shown that replacing "raise HTTPError(response)" with "raise None" results in the same outcome.

Possibly removing the "raise" and just call the function on its own will fix this, but I'm unsure what the intended effect was suppose to be.

CODE SNIPPET

    while True:
        try:
            response = self.handler(url, message, **kwargs)
            break
        except Exception:
            if self.retries <= 0:
                raise
            else:
                time.sleep(self.retryDelay)
                self.retries -= 1
    response = record(response)
    if 400 <= response.status:
        raise HTTPError(response)

joroger avatar Feb 02 '25 20:02 joroger