[Bug]: json-xml-mediator policy accepts XML with more than one root element
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go, json, xml
- Domain
- backend-api-design
Research direction
Start in the json-xml-mediator policy's XML parsing path, where the issue says xml.Unmarshal reads the first element and ignores trailing content. Check the policy's tests for malformed XML and add coverage for a document with two root elements. Done means that request returns 500 and is not forwarded to the backend.
Written by the indexing model from the issue text.
Description
Please select the area the issue is related to
Gateway
Please select the aspect the issue is related to
Aspect/API (API backends, definitions, contracts, interfaces, OpenAPI)
Description
The policy parses XML with xml.Unmarshal, which reads the first element and stops. Anything after that element is ignored.
So a document with two root elements is not well-formed, yet it passes. The policy converts the first element, drops the rest and forwards the result. The backend never learns that part of the request was lost.
Malformed XML that fails inside the first element is rejected with 500, as the policy documentation describes for malformed payloads.
Expected Behaviour
The request is rejected with 500 and does not reach the backend.
Actual Behaviour
The gateway answers 200. The backend receives {"order":{"sku":"W-1"}}, and the second <order> is lost.
Steps to Reproduce
- Create a REST API with the policy on a POST operation:
{"name":"json-xml-mediator","version":"v1","params":{"downsteamPayloadFormat":"xml","upstreamPayloadFormat":"json"}} - Send
<order><sku>W-1</sku></orders>withContent-Type: application/xml. The gateway answers 500, and the backend is not called. - Send
<order><sku>W-1</sku></order><order><sku>G-2</sku></order>. The gateway answers 200, and the backend receives{"order":{"sku":"W-1"}}.
Severity Level of the Issue
Severity/Major (Important functionality is broken. Should be prioritized. Doesn't need immediate attention)
Environment Details (with versions)
- Gateway versions: 1.1.0, 1.2.0 and latest
- Policy:
json-xml-mediatorv1.1.0, wso2/gateway-controllers main5b8e3367 - Upstream: a test service that records the request body
- Dominant language
- Go
- Stars
- 85
- Forks
- 142
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 250
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wso2/api-platform
-
Area/Policies Aspect/API Severity/Major Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/api-platform#4465 ·
Maintainers usually reply within 1 day
-
[Bug]: Invalid [api_portal.http_client.tls] value reports an error naming server.httpsPossibly taken @Maheesh09 claimed this 1 day ago. OpenArea/DeveloperPortal Aspect/Configuration Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/api-platform#4437 · 1 comment ·
Maintainers usually reply within 1 day
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
wso2/api-platform#4369 ·
Maintainers usually reply within 1 day
-
[Bug]: host-rewrite policy documentation lists fewer allowed host characters than the policy acceptsOpenArea/Policies Aspect/Other Severity/Trivial Type/Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
wso2/api-platform#4355 ·
Maintainers usually reply within 1 day
-
[Bug]: A refused request's analytics event and traffic log lose the path the client calledMay be free again A pull request for this issue was closed without being merged. OpenArea/Gateway Aspect/API Severity/Minor Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/api-platform#4348 ·
Maintainers usually reply within 1 day
All issues in wso2/api-platform
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
github/github-mcp-server#3960 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
JuliusBrussee/caveman#1594 ·
Maintainers usually reply within 1 day
-
C-bug O-community X-blathers-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
cockroachdb/cockroach#176264 · 1 comment ·