[Bug 43491] New: REST API XML payload conversion breaks plugin API routes that read XML
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Bug ID: 43491 Summary: REST API XML payload conversion breaks plugin API routes that read XML Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: kyle@bywatersolutions.com QA Contact: tomascohen@gmail.com CC: tomascohen@gmail.com Target Milestone: --- Bug 37762 makes the REST API convert request bodies sent with an application/xml content type to JSON so they can be validated against Koha's swagger definitions, and convert response bodies with an application/xml content type from JSON to XML. Both hooks apply to every route, including the /contrib plugin routes. Plugins define their own API and may consume and produce XML directly. I've been working on a plugin based version of the NCIP server for Koha, with NCIP being entirely XML based. On Koha 26.05 and later the request hook replaces the incoming NCIP message with a JSON rendering of it before the plugin controller runs. The conversion drops element attributes and ordering, so the original message can't be rebuilt from it. In my case it's the attributes that are needed. I have found a workaround by grabbing the raw body from the buffered PSGI input Mojolicious's $c variable. In the other direction, the response hook dies trying to parse the plugin's XML response as JSON, turning it into a 500. This affects Koha 26.05+ -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |kyle@bywatersolutions.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |37762 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37762 [Bug 37762] Expand ILL to allow for supplying agency/lending library workflows -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |major --- Comment #1 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- This also affects koha-plugin-twilio-voice and koha-plugin-twilio-interactive-sms, which is much more important than my NCIP plugin POC! Bumping importance to major. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pedro.amorim@openfifth.co.u | |k --- Comment #2 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Hi Kyle, how does this differ from bug 43460? Thank you. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff --- Comment #3 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- b1530f3: Bug 43491: Add unit tests 30bdb67: Bug 43491: REST API XML payload conversion breaks plugin API routes that read XML -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 --- Comment #4 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 205435 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205435&action=edit Bug 43491: Add unit tests Patch from commit b1530f3 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 --- Comment #5 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- Created attachment 205436 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=205436&action=edit Bug 43491: REST API XML payload conversion breaks plugin API routes that read XML Bug 37762 makes the REST API convert request bodies sent with an application/xml content type to JSON so they can be validated against Koha's swagger definitions, and convert response bodies with an application/xml content type from JSON to XML. Both hooks apply to every route, including the /contrib plugin routes. Plugins define their own API contracts and may consume and produce XML directly. For example, the NCIP server plugin accepts NCIP XML messages on its route. On Koha 26.05 and later the request hook replaces the incoming NCIP message with a JSON rendering of it before the plugin controller runs, destroying the message, and the response hook dies trying to parse the plugin's XML response as JSON. This patch skips both conversions for the contrib namespace, using the same namespace detection as Koha::REST::V1::Auth. Core routes such as the ISO18626 endpoint are unaffected. Test Plan: 1) Apply the first patch 2) prove t/db_dependent/Koha/REST/Plugin/PluginRoutes.t 3) Note the new 'XML payloads on plugin routes tests' subtest fails, the XML and JSON bodies come back mangled! 4) Apply this patch 5) prove t/db_dependent/Koha/REST/Plugin/PluginRoutes.t 6) Note all tests pass! 7) prove t/db_dependent/api/v1/iso18626/request.t 8) Note the core XML conversion still works! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 Kyle M Hall (khall) <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |RESOLVED Resolution|--- |DUPLICATE --- Comment #6 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- *** This bug has been marked as a duplicate of bug 43460 *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43491 --- Comment #7 from Kyle M Hall (khall) <kyle@bywatersolutions.com> --- (In reply to Pedro Amorim (ammopt) from comment #2)
Hi Kyle, how does this differ from bug 43460? Thank you.
My bad, I didn't realize I filed this bug report twice, and then also did not check for new comments! -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org