gurock / trcli

TR CLI (trcli) is a command line tool for interacting with TestRail.
Mozilla Public License 2.0
48 stars 39 forks source link

KeyError: 'section_id' when trying to processed a combined junit test report #151

Closed victor-chan-groundswell closed 10 months ago

victor-chan-groundswell commented 1 year ago

TestRail CLI Version

1.5

CLI Environment

MacOS

TestRail Version

TestRail v7.8.0 Default (1141)

TestRail Instance Type

Professional Cloud

Current behavior

It seems that, if I combine multiple junit test suites into one file (I tried to use either jrm or junitparser but the results are the same), it errors out with the following....

This behavior ONLY happens when I combine the junit reports... If I were to pick just one report file from my suite, it works fine.

I would guess that maybe there's something to the project side that we might have to add?

`
Adding missing test cases to the suite. Adding test cases: 0/1 Traceback (most recent call last): File "/opt/homebrew/bin/trcli", line 8, in sys.exit(cli()) ^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1130, in call return self.main(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 760, in invoke return __callback(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/decorators.py", line 84, in new_func return ctx.invoke(f, obj, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 760, in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/trcli/commands/cmd_parse_junit.py", line 92, in cli result_uploader.upload_results() File "/opt/homebrew/lib/python3.11/site-packages/trcli/api/results_uploader.py", line 90, in upload_results added_test_cases, result_code = self.add_missing_test_cases() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/trcli/api/results_uploader.py", line 289, in add_missing_test_cases added_cases, result_code = self.prompt_user_and_add_items( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/trcli/api/results_uploader.py", line 313, in prompt_user_and_add_items added_items, error_message = add_function() ^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/trcli/api/api_request_handler.py", line 347, in add_cases responses, error_message = self.handle_futures( ^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/trcli/api/api_request_handler.py", line 454, in handle_futures response = future.result() ^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 449, in result return self.get_result() ^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/trcli/api/api_request_handler.py", line 556, in _add_case_and_update_data response = self.client.send_post(f"add_case/{case_body.pop('section_id')}", case_body)

KeyError: 'section_id' `

When I tried to run this with the --verbose flag on, the last API call where it seemes to be successful, then it leads to the error is this....

` **** API Call method: POST url: https://OURCLOUDTESTRAILSURL/index.php?/api/v2/add_section/4 payload: {'name': 'Corporate Login ', 'suite_id': 231} response status code: 200 response body: {'id': 2691, 'suite_id': 231, 'name': 'Corporate Login', 'description': None, 'parent_id': None, 'display_order': 14, 'depth': 0}


Adding missing test cases to the suite. Adding test cases: 0/1 Traceback (most recent call last): File "/opt/homebrew/bin/trcli", line 8, in sys.exit(cli()) ^^^^^`

Desired behavior

A more verbose error in telling us what's needed in the project, if that's the case...

More Details

No response

victor-chan-groundswell commented 1 year ago

I actually found out why... It turns out that, on our cypress tests, one of the tests has a whitespace....

While I work with the folks who wrote these tests on it, I wonder why this would fail so... weirdly?

image

d-rede commented 10 months ago

Hello @victor-chan-groundswell

Can I ask you to kindly provide a report (or multiple reports to be merged) so that we can debug this issue? It really is odd that a whitespace would cause so much trouble.

Thanks

d-rede commented 10 months ago

Closing this issue since it's not an active blocker, but don't hesitate to re-open or send in new evidence.