IndexError masks failures from JavaScript extension keywords with *args
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 Browser/browser.py 中的 _get_selector_value_from_keyword_call() 开始,追踪它如何将传入的值与 keyword 签名匹配。使用提供的 JavaScript 扩展和 Robot 测试复现该问题。完成标准是失败报告原始错误 boom: ["a","b"],而不是引发 IndexError。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 662
- 派生
- 149
- 平均合并
- 6 小时 13 分钟
- 30 天内合并 PR
- 121
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MarketSquare/robotframework-browser 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
MarketSquare/robotframework-browser#5153 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
MarketSquare/robotframework-browser#5503 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 78/100
MarketSquare/robotframework-browser#5502 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 54/100
MarketSquare/robotframework-browser#5501 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 76/100
MarketSquare/robotframework-browser#5500 ·
维护者通常 1 天内回复
查看 MarketSquare/robotframework-browser 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
igormcsouza/tether#278 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
aws-samples/sample-per-model-bedrock#803 ·
维护者通常 1 天内回复
-
documentation p1
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
huggingface/accelerate#4511 ·
维护者通常 1 天内回复
-
follow-up
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复