Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TicketCreate() assumes falsely that a ticket number looks like a number (an int) #46

Open
vincentborghi opened this issue Mar 15, 2021 · 3 comments

Comments

@vincentborghi
Copy link

My OTRS instance has a specific ticket number generator, so ticket numbers are not made of digits only (an example of ticket number in my system is "210315-VT1203" ). Apparently (and if I understand), non-numeric ticket numbers cause TicketCreate() to fail when it generates its return infos.

For example I have a ticket number like "210315-VT1203" and I obtained this error (although the ticket is created as expected):
Traceback (most recent call last):
File "./testpyotrs.py", line 45, in
createtest()
File "./testpyotrs.py", line 37, in createtest
client.tc.TicketCreate(t, a,) # [df1, df2], [att1])
File "/usr/local/lib/python3.6/site-packages/otrs/client.py", line 109, in add_auth
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/otrs/ticket/operations.py", line 46, in call
infos = {extract_tagname(i): int(i.text) for i in elements}
File "/usr/local/lib/python3.6/site-packages/otrs/ticket/operations.py", line 46, in
infos = {extract_tagname(i): int(i.text) for i in elements}
ValueError: invalid literal for int() with base 10: '210315-VT1203'

Thanks

@vincentborghi
Copy link
Author

Same issue is found when calling TicketUpdate().
...and posibly other places where int(i.text) is applied to the ticket number...

@ewsterrenburg
Copy link
Owner

Agreed that the assumption of a ticket number that strictly consists of numbers should be removed. Will think about how to implement this (pull request is also welcome...)

@vincentborghi
Copy link
Author

As a workaround, I have modified my python-otrs/otrs/ticket/operations.py as follows (just a quick hack that probably could be even simpler, shown below as a diff). The statement that hurts is:
infos = {extract_tagname(i): int(i.text) for i in elements}

It appears in the "class TicketCreate" and in the "class TicketUpdate" definitions, so I applied the change the change to both places.


$ diff  python-otrs/otrs/ticket/operations.py.ori  python-otrs/otrs/ticket/operations.py
46c46,55
<         infos = {extract_tagname(i): int(i.text) for i in elements}
---
> #VBorghi 2021-03-17 patch to circumvent problem as we have ticket numbers containing non-digits
> #        infos = {extract_tagname(i): int(i.text) for i in elements}
>         infos = {}
>         for i in elements:
>             tagname = extract_tagname(i)
>             if tagname == 'TicketID':
>                 infos[tagname] = int(i.text)
>             elif tagname == 'TicketNumber':
>                 infos[tagname] = i.text   
> # End of patch
49a59
> 
170c180,189
<         infos = {extract_tagname(i): int(i.text) for i in elements}
---
> #VBorghi 2021-03-17 patch to circumvent problem as we have ticket numbers containing non-digits
> #        infos = {extract_tagname(i): int(i.text) for i in elements}
>         infos = {}
>         for i in elements:
>             tagname = extract_tagname(i)
>             if tagname == 'TicketID':
>                 infos[tagname] = int(i.text)
>             elif tagname == 'TicketNumber':
>                 infos[tagname] = i.text   
> # End of patch
171a191
> 


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants