splunk / splunk/splunk-sdk-python

splunklib.binding.HTTPlib.request improper exception handling.

Aperta
#599 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
743
Fork
387
Merge medio
42m
PR unite (30g)
4

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Start at splunklib.binding.HTTPlib.request around line 1345 and inspect the definition of HTTPError and the retry loop. Confirm the intended behavior for responses with status 400 or greater, then add or update coverage to verify that the intended exception is raised without the generic BaseException error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.