[BUG] ModifyResponsePlugin always parses and re-serializes response body as JSON even for header-only configurations
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-modify-response/.../ModifyResponsePlugin.java:148-171`
- description: In `writeWith`, `modifyBody(bytes)` is unconditionally called regardless of whether any body modification rules are configured. `JsonPath.parse(jsonValue)` is always called and `context.jsonString()` always re-serializes. For non-JSON responses (XML, HTML, binary), `JsonPath.parse` throws → `ShenyuException`.
- impact: (a) Non-JSON responses crash the plugin even when only header modifications are configured. (b) Re-serialization can change whitespace/key ordering for valid JSON.
- suggested_fix: Short-circuit `modifyBody` when all body-key lists are empty/null; add a content-type guard.
- confidence: Medium
- related_existing: none
---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in shenyu-plugin/shenyu-plugin-modify-response/.../ModifyResponsePlugin.java:148-171, read writeWith and modifyBody, and trace the body-key lists and content type handling. Verify that header-only configurations pass through non-JSON bodies without parsing, while configured JSON responses retain the intended modifications without unnecessary re-serialization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100