execute commond error
sirfengyu opened this issue · 5 comments
sirfengyu commented
yudeMacBook-Pro:Downloads yufeng$ har2case Untitled1.har
Traceback (most recent call last):
File "/usr/local/bin/har2case", line 11, in <module>
load_entry_point('har2case==0.0.7', 'console_scripts', 'har2case')()
File "/usr/local/lib/python3.6/site-packages/har2case-0.0.7-py3.6.egg/har2case/cli.py", line 60, in main
har_parser = HarParser(har_source_file, args.filter, args.exclude)
File "/usr/local/lib/python3.6/site-packages/har2case-0.0.7-py3.6.egg/har2case/core.py", line 63, in __init__
self.testset = self.make_testset()
File "/usr/local/lib/python3.6/site-packages/har2case-0.0.7-py3.6.egg/har2case/core.py", line 288, in make_testset
testset = self.make_testcases()
File "/usr/local/lib/python3.6/site-packages/har2case-0.0.7-py3.6.egg/har2case/core.py", line 267, in make_testcases
{"test": self.make_testcase(entry_json)}
File "/usr/local/lib/python3.6/site-packages/har2case-0.0.7-py3.6.egg/har2case/core.py", line 249, in make_testcase
self._make_request_data(testcase_dict, entry_json)
File "/usr/local/lib/python3.6/site-packages/har2case-0.0.7-py3.6.egg/har2case/core.py", line 161, in _make_request_data
post_data = entry_json["request"]["postData"]["text"]
KeyError: 'text'
debugtalk commented
@sirfengyu 可否将原始的HAR
文件发来看下?
debugtalk commented
重新看了下HAR
的标准规范,是我理解错了,这里的确是有个bug。
"postData": {
"mimeType": "multipart/form-data",
"params": [],
"text" : "plain posted data",
"comment": ""
}
mimeType [string] - Mime type of posted data.
params [array] - List of posted parameters (in case of URL encoded parameters).
text [string] - Plain text posted data
comment [string, optional] (new in 1.2) - A comment provided by the user or the application.
Note that text and params fields are mutually exclusive.
有些请求类型的postData
中是text
,有些是params
,并且两者互斥。
之前只考虑了text
这种情况,而你的案例中用的是params
,我修复下吧。
debugtalk commented
@sirfengyu 我刚修复了下,你升级到最新版再试下。
sirfengyu commented
还是同样的har文件:报如下错误
yudeMacBook-Pro:Downloads yufeng$ har2case demo.har demo.yml
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/har2case", line 11, in <module>
load_entry_point('har2case==0.0.8', 'console_scripts', 'har2case')()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/har2case-0.0.8-py2.7.egg/har2case/cli.py", line 60, in main
har_parser = HarParser(har_source_file, args.filter, args.exclude)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/har2case-0.0.8-py2.7.egg/har2case/core.py", line 63, in __init__
self.testset = self.make_testset()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/har2case-0.0.8-py2.7.egg/har2case/core.py", line 296, in make_testset
testset = self.make_testcases()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/har2case-0.0.8-py2.7.egg/har2case/core.py", line 275, in make_testcases
{"test": self.make_testcase(entry_json)}
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/har2case-0.0.8-py2.7.egg/har2case/core.py", line 258, in make_testcase
self._make_validate(testcase_dict, entry_json)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/har2case-0.0.8-py2.7.egg/har2case/core.py", line 219, in _make_validate
resp_content_json = json.loads(content.decode('utf-8'))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
debugtalk commented
@sirfengyu 修复了,问题在于你测试系统的Content-Type
为application/jose
,这种情况之前是没有兼容的。现在已经好了。