Skip to content

Commit 1dc68d2

Browse files
committed
<fix>[errorcode]: revert sendReplyResponse to use JSONObjectUtil serialization
CloudBusGson.httpGson does not disableHtmlEscaping(), causing single quotes in error details to be escaped as \u0027. While valid JSON, the SDK deserializes these literally, breaking string assertions in tests like BatchAddBareMetal2ChassisCase that check error.details with contains("'reboot' must be 'No'"). Restore JSONObjectUtil.toJsonString() for the sendReplyResponse error path while keeping the centralized localization logic. Co-Authored-By: ye.zou <ye.zou@zstack.io>
1 parent aaf4e34 commit 1dc68d2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

rest/src/main/java/org/zstack/rest/RestServer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,8 +1439,13 @@ private void sendReplyResponse(MessageReply reply, Api api, HttpServletResponse
14391439
ApiResponse response = new ApiResponse();
14401440

14411441
if (!reply.isSuccess()) {
1442+
String locale = resolveLocale();
1443+
i18nService.localizeErrorCode(reply.getError(), locale);
14421444
response.setError(reply.getError());
1443-
sendResponse(HttpStatus.SERVICE_UNAVAILABLE.value(), response, rsp);
1445+
// use JSONObjectUtil (which disables HTML escaping) to keep the same
1446+
// serialization behavior as before; CloudBusGson.httpGson escapes '\'' to
1447+
// '\u0027' which breaks SDK-side string assertions (ZSTAC-71075 etc.)
1448+
sendResponse(HttpStatus.SERVICE_UNAVAILABLE.value(), JSONObjectUtil.toJsonString(response), rsp);
14441449
return;
14451450
}
14461451

0 commit comments

Comments
 (0)