You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/03 00:50:16 UTC

[I] [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses [shenyu]

Aias00 opened a new issue, #6633:
URL: https://github.com/apache/shenyu/issues/6633

   - Severity: High
   - Location:
   `shenyu-plugin/shenyu-plugin-modify-response/src/main/java/org/apache/shenyu/plugin/modify/response/ModifyResponsePlugin.java:98-107` (`writeWith` always calls `modifyBody(bytes)`), `:160` (`modifyBody(String)` unconditionally calls `JsonPath.parse(jsonValue)`)
   - 
   Description:
   `writeWith` (line 98-107) always calls `modifyBody(bytes)`. `modifyBody(String)` (line 160) unconditionally executes `DocumentContext context = JsonPath.parse(jsonValue);` **before** and **regardless of** whether any `addBodyKeys`/`replaceBodyKeys`/`removeBodyKeys` are configured. The body-key branches at lines 161-169 are conditional, but the parse is not. If the matched route returns a non-JSON body (binary/image, HTML, plain text, CSS/JS, or an empty 204 body), `JsonPath.parse` throws `InvalidJsonException`. The catch at line 153-156 wraps it into a `ShenyuException`, producing a 500 instead of passing the response through.
   - 
   Impact:
   A header-only ModifyResponse rule (only `addHeaders`/`setHeaders`/`replaceHeaderKeys`/`removeHeaderKeys`/`statusCode`) applied to any non-JSON response corrupts valid responses with a 500.
   - 
   Suggested fix:
   In `modifyBody(String)`, return the body unchanged when `addBodyKeys`, `replaceBodyKeys`, and `removeBodyKeys` are all empty, skipping `JsonPath.parse` entirely.
   - 
   Confidence: High
   - Related existing: #6510 is the `replaceHeaderKeys` name-vs-value bug in `modifyResponseHeadersAndStatus`; this is a separate body-parsing bug.
   
   ---
   _Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/00-consolidated-critical-high.md`](docs/scan2-2026-08-02/00-consolidated-critical-high.md)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses [shenyu]

Posted by "Aias00 (via GitHub) via notifications" <no...@shenyu.apache.org>.
Aias00 closed issue #6633: [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses
URL: https://github.com/apache/shenyu/issues/6633


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses [shenyu]

Posted by "sunnysabor (via GitHub)" <gi...@apache.org>.
sunnysabor commented on issue #6633:
URL: https://github.com/apache/shenyu/issues/6633#issuecomment-5931853223

   This issue appears resolved by merged [PR #7131](https://github.com/apache/shenyu/pull/7131) (`cd514ff29`, merged 2026-09-20). `ModifyResponseDecorator.writeWith` now passes through when there are no body modifications or the response content type is not JSON, and the PR added regression cases for header-only HTML and body rules on XML. I verified the current code with `./mvnw -pl shenyu-plugin/shenyu-plugin-modify-response -Dtest=ModifyResponsePluginTest -Djacoco.skip=true -Dmaven.javadoc.skip=true test`: 8 tests pass and Checkstyle reports 0 violations. The issue can be closed as fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses [shenyu]

Posted by "wy471x (via GitHub)" <gi...@apache.org>.
wy471x commented on issue #6633:
URL: https://github.com/apache/shenyu/issues/6633#issuecomment-5975482621

   /assign


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses [shenyu]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #6633:
URL: https://github.com/apache/shenyu/issues/6633#issuecomment-5161208614

   👋 Hello @Aias00
   
   A new issue has been opened by @Aias00:
   - **Title**: [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses
   - **Link**: https://github.com/apache/shenyu/issues/6633
   
   Please review when you have time. Thank you! 🙏


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [BUG] ModifyResponsePlugin unconditionally parses the response body as JSON, breaking non-JSON responses [shenyu]

Posted by "Aias00 (via GitHub) via notifications" <no...@shenyu.apache.org>.
Aias00 commented on issue #6633:
URL: https://github.com/apache/shenyu/issues/6633#issuecomment-6791277082

   Verified against current master (9dd9a12fb). Merged PR #7131 (cd514ff29) makes `ModifyResponsePlugin` pass non-JSON responses, and responses without body modifications, through unchanged (see `isJsonResponse()`). Closing as resolved.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org