reportportal / agent-Python-RobotFramework

Robot Framework integration for Report Portal
Apache License 2.0
59 stars 32 forks source link

Accessing empty _stack variable by index #104

Closed ezequiel-atencio closed 3 years ago

ezequiel-atencio commented 3 years ago

package versions: robotframework-reportportal 5.1.1 reportportal-client 5.0.10 robotframework 4.0

When calling

post_report --variable RP_MODE:"DEBUG" --variable RP_UUID:"beedce22-948a-4e79-ad6f-c8b12bedd1eb" --variable RP_ENDPOINT:"http://some_url:8080/" --variable RP_LAUNCH:"trying_report_portal" --variable RP_PROJECT:"SANDBOX" output_googlechrome.xml

the following error occurs:

Traceback (most recent call last):
  File "C:\Python38\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python38\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "X:\Projects\hr_automation\.temp\pvenv\Scripts\post_report.exe\__main__.py", line 7, in <module>
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robotframework_reportportal\post_report.py", line 73, in main
    process(*values)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robotframework_reportportal\post_report.py", line 43, in process
    test_run.visit(TimeVisitor())
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\result\executionresult.py", line 120, in visit
    visitor.visit_result(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\result\visitor.py", line 44, in visit_result
    result.suite.visit(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\testsuite.py", line 195, in visit
    visitor.visit_suite(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\visitor.py", line 87, in visit_suite
    suite.suites.visit(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\itemlist.py", line 77, in visit
    item.visit(visitor)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\testsuite.py", line 195, in visit
    visitor.visit_suite(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\visitor.py", line 87, in visit_suite
    suite.suites.visit(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\itemlist.py", line 77, in visit
    item.visit(visitor)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\testsuite.py", line 195, in visit
    visitor.visit_suite(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\visitor.py", line 88, in visit_suite
    suite.tests.visit(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\itemlist.py", line 77, in visit
    item.visit(visitor)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\testcase.py", line 103, in visit
    visitor.visit_test(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\visitor.py", line 111, in visit_test
    test.body.visit(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\itemlist.py", line 77, in visit
    item.visit(visitor)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\keyword.py", line 75, in visit
    visitor.visit_keyword(self)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robot\model\visitor.py", line 137, in visit_keyword
    self.end_keyword(kw)
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robotframework_reportportal\time_visitor.py", line 71, in end_keyword
    self._correct_ends(keyword, "kw")
  File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robotframework_reportportal\time_visitor.py", line 52, in _correct_ends
    if o.id == _stack[-1]:
IndexError: list index out of range

The issue is that the code tries to access the _stack variable by index and it's empty, triggering the index error.

if o.id == _stack[-1]:
IndexError: list index out of range

If that part of the code is commented or a stub variable is inserted in the _stack variable, the code moves on, giving another error while trying to acces the "source" key of the Test class attributes dictionary:

File "x:\projects\hr_automation\.temp\pvenv\lib\site-packages\robotframework_reportportal\model.py", line 83, in __init__
self.code_ref = '{0}:{1}'.format(attributes['source'], name)
KeyError: 'source'

I'm attaching the output.xml file used output_googlechrome.zip