Skip to content

Providing an empty ticketlist to ticket_get_by_list yields an empty result

senfomat requested to merge senfomat/PyOTRS:master into master

When I did this in my code using PyOTRS:

1: ticketList = client.ticket_search(Queues=["MyQueue"], States=["open", "new"], Locks=["unlock"])
2:
3: for ticket in client.ticket_get_by_list(ticketList, dynamic_fields=False, attachments=True, articles=True):
4:       pass

and the ticketList-variable is empty in line 1, the for-loop in line 3 crashed with the misleading error-nessage/Exception:

Traceback (most recent call last):
  File "./pyOtrsTest.py", line 37, in <module>
    main()
  File "./pyOtrsTest.py", line 30, in main
    ticketList, dynamic_fields=False, attachments=True, articles=True
  File "/home/senfomat/p/venv/lib/python3.6/site-packages/pyotrs/lib.py", line 1207, in ticket_get_by_list
    if not self._parse_and_validate_response(self._send_request(payload)):
  File "/home/senfomat/p/venv/lib/python3.6/site-packages/pyotrs/lib.py", line 1983, in _parse_and_validate_response
    self.result_json["Error"]["ErrorMessage"]))
pyotrs.lib.APIError: Failed to access OTRS API. Check Username and Password! Session ID expired?! Does Ticket exist?
OTRS Error Code: TicketGet.MissingParameter
OTRS Error Message: TicketGet: TicketID parameter is missing!

The proposed change returns an empty list from ticket_get_by_list() when the provided ticketList is empty. (="you ask for nothing, you get an empty answer"). I hope this does not break anything.

Merge request reports