python-otrs icon indicating copy to clipboard operation
python-otrs copied to clipboard

In otrs/objects.py, assumptions made by "autocast" are error-prone (for values with a leading zero)

Open vincentborghi opened this issue 4 years ago • 1 comments

In my use case, I have a dynamic field "SR Number" which stores some external ticket number. The fact is that those ticket numbers are made of digits only and may begin with "0" (zero), like e.g. "01234567". When I search for tickets whose dynamic field "SR Number" is e.g. "01234567", this fails, because autocast changes the string value "01234567" to the "1234567" int, while I need it just stays as it is (the string "01234567").

I was obliged to modify the autocast function (in otrs/objects.py) by adding the 2 following lines just before the "try" statement: if s.startswith("0"):
return s

vincentborghi avatar Apr 19 '21 08:04 vincentborghi

Agreed that the current version is "too greedy", yet couldn't come to a simple fix yet that's doing the right thing in both Python 2 & Python 3 (your workaround doesn't work when the ticket numbers involved are actually integers).

Will think about it and look at this as well when scrapping out Python 2 compatibility.

ewsterrenburg avatar Feb 15 '22 12:02 ewsterrenburg