[Bug]: json-xml-mediator policy writes large and small JSON numbers in exponent form
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start by locating the json-xml-mediator policy code that formats JSON numbers with Go's %g verb; the issue identifies the policy and the affected behavior but no file or test. Check how existing policy tests cover JSON-to-XML conversion, then add cases for 1234567 and 0.00001. Done means those XML elements preserve the decimal values instead of using exponent notation, with the relevant tests passing.
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 json-xml-mediator policy converts a JSON request to XML for the backend. It formats every JSON number with Go's %g verb.
%g switches to exponent form for numbers of a million or more and for numbers below 0.0001. So 1234567 reaches the backend as 1.234567e+06, and 0.00001 as 1e-05. An XML backend that expects decimal digits rejects or misreads these values.
Numbers between 0.0001 and a million are not affected. The policy doc says the policy converts all JSON data types.
Expected Behaviour
The XML element holds the number as the JSON wrote it, such as 1234567 and 0.00001.
Actual Behaviour
The backend receives <root><population>1.234567e+06</population><ratio>1e-05</ratio></root>.
Steps to Reproduce
- Create a REST API with the policy on a POST operation:
{"name":"json-xml-mediator","version":"v1","params":{"downsteamPayloadFormat":"json","upstreamPayloadFormat":"xml"}} - Send
{"population":12345,"ratio":0.5}withContent-Type: application/json. The backend receives<root><population>12345</population><ratio>0.5</ratio></root>. - Send
{"population":1234567,"ratio":0.00001}. The backend receives<root><population>1.234567e+06</population><ratio>1e-05</ratio></root>.
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 76/100
wso2/api-platform#4468 ·
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 ·