IndexError masks failures from JavaScript extension keywords with *args
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
Direzione di ricerca
Inizia da _get_selector_value_from_keyword_call() in Browser/browser.py e segui come associa i valori passati alla firma della keyword. Riproduci il problema con l’estensione JavaScript e il test Robot forniti. Il lavoro è terminato quando l’errore segnala l’errore originale boom: ["a","b"] invece di sollevare IndexError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When a JavaScript extension keyword declares a parameter named args and is called with multiple positional arguments, a keyword failure can be replaced by an IndexError during Browser’s failure handling. This hides the original exception and makes the failure difficult to diagnose.
To Reproduce
Steps to reproduce the behavior:
JavaScript extension:
async function boom(args) {
throw new Error(`boom: ${JSON.stringify(args)}`);
}
exports.Boom = boom;
Robot test:
*** Test Cases ***
Failure Should Preserve Original Error
Boom a b
Expected behavior
The JavaScript keyword receives both values, but the failure handling path raises IndexError: list index out of range while inspecting the keyword arguments, instead of reporting the original boom: ["a","b"] error.
cause
The generated Python signature turns a JavaScript parameter called args into *args. When _get_selector_value_from_keyword_call() tries to match the values passed to the keyword with the keyword signature, it checks the actual values instead of the signature itself. With multiple values, it can end up looking past the end of the signature and throw an IndexError.
suggested fix
Change _get_selector_value_from_keyword_call() method to:
def _get_selector_value_from_keyword_call(self, name, args, kwargs):
selector = kwargs.get("selector")
if not selector and args:
arguments = self.get_keyword_arguments(name)
for i, arg in enumerate(args):
if i >= len(arguments):
break
spec = arguments[i][0] if isinstance(arguments[i], tuple) else arguments[i]
if spec.startswith("*"):
break
if spec.startswith("selector"):
selector = arg
break
return selector
Desktop (please complete the following information):
- OS: Windows 11
- Browser: chromium
- Version: 151.0.7922.34
- Lingua principale
- Python
- Stelle
- 662
- Fork
- 149
- Merge medio
- 6h 13m
- PR unite (30g)
- 121
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MarketSquare/robotframework-browser
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MarketSquare/robotframework-browser#5153 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
MarketSquare/robotframework-browser#5503 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
MarketSquare/robotframework-browser#5502 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
MarketSquare/robotframework-browser#5501 ·
I maintainer di solito rispondono entro 1 giorno
-
Accept a list of credentials in `httpCredentials` of `New Context` and `New Persistent Context`Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
MarketSquare/robotframework-browser#5500 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MarketSquare/robotframework-browser
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
igormcsouza/tether#278 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
aws-samples/sample-per-model-bedrock#803 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
huggingface/accelerate#4511 ·
I maintainer di solito rispondono entro 1 giorno
-
follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno