-
Notifications
You must be signed in to change notification settings - Fork 74
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
Error while JSON::PP::Boolean key exists in incoming XML mapping #3765
Comments
Hi Roman, this looks indeed like a bug in OTOBO. This occurs when the JSON returned from Gitlab is converted to XML. The reference to JSON::PP::Boolean are to be expected in the parsed JSON. They represent boolean values. But XML::Simple does not know how to handle these references. See otobo/Kernel/GenericInterface/Mapping/XSLT.pm Line 255 in 5c04fd3
@romanpilipovskiy , which version of OTOBO are you running? |
@bschmalhofer 11.0.5 |
There is a bug in JSON::XS, I think we have to use Cpanel::JSON::XS in the long term. It works with that. Workaround: Then adjust the file Custom/Kernel/System/JSON.pm and replace all occurrences of JSON::XS with Cpanel::JSON::XS. Insert the following line below the line ‘$JSONObject->allow_nonref(1);’ in the ‘sub Decode’: $JSONObject->unblessed_bool([1]); @bschmalhofer: I think we need to switch to Cpanel::JSON::XS at least for 11.1, or what do you think? |
I think there was a reason for not using Cpanel::JSON::XS, even though it did appeal to me initially. I'll try to find that reason. Instead of using |
The problem with I see that otobo/Kernel/GenericInterface/Mapping/XSLT.pm Line 255 in 5c04fd3
XML::Simple::XMLOut() directly. Switching to using the module Kernel::System::XML::Simple, which is using XML::LibXML::Simple internally, is not an option. This is because XML::LibXML::Simple only provides XML In() . So I propose to use https://metacpan.org/pod/XML::Simple#Handler-=%3E-object_ref-#-out-SAX-only to generate real booleans in the generated XML. I think that this is the most intuitive option. Boolean values in JSON should also be used as Boolean XML values in the XSLT transformation.
TODO:
|
Hi Bernhard, ok thanks, that's fine for me. We have access to a test case and I'm able to share it. Thanks! |
use subtests for grouping related tests
I checked how the XSLT mapping parsed the XML that was generated from the passed data. No schema information is given for the XML source. This means that XSLT templates need to match on the strings 'true' and 'false'. This is fine. |
For my understanding: Is this not making the whole "having a real boolean in the XML", which I understand is the aim of using SAX, superfluous? If in XSLT we are checking for strings anyways, then let's not do all the hassle and rather just use |
I would still prefer to do it the more "correct" way. At the end of the day, adding the |
Passt ;) - the pod of the SAX packages just looked a lot more involved than the one method of either JSON::XS implementation. So if it doesn't come with a whole new set of dependencies, significantly more code, and/or computational effort, I'm fine with either solution. |
I did some further digging as the cause and thehistory of this bug is a bit convoluted. The OTOBO releases 10.0 and 10.1 were using the module The bug was introduced in #399 where The question remains why the significant change was not detected by the unit tests. This has to do with the peculiarities of So the fix for OTOBO 11.0.x is to not emit blessed references, which confuse My previous idea was to tweak the behavior of |
use subtests for grouping related tests
more precisely, with test input that is the result of parsing JSON
use subtests for grouping related tests
more precisely, with test input that is the result of parsing JSON
Hi @romanpilipovskiy , sorry, this looks like a bug that was introduced in OTOBO 11.0.1. The behavior had changed and unfortunately the test suite did not catch the change. I have created a fix that restores the behavior from OTOBO 10.1.x. The JSON boolean values The fix will be included in the next patch release. In the meantime you could apply the hotfix to your installation,
|
@bschmalhofer Thank you! |
A similar issue was reported for OTOBO 11.0.x in the OTOBO forum https://otobo.io/forums/topic/json-issues-after-migrating-to-otobo-11/ . |
When trying to integrate OTOBO with GitLab, I get an error when processing the response message, since it contains fields with a value
'has_tasks' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
or'locked' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ),
Errors:
Can't encode a value of type: JSON::PP::Boolean at /opt/otobo/Kernel/GenericInterface/Mapping/XSLT.pm
Could not convert data from Perl to XML before mapping
The text was updated successfully, but these errors were encountered: