From 78ed5a0235c4de67828ba4b0d6147035067cec2c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 31 Jul 2026 17:45:07 -0400 Subject: [PATCH] refac Co-Authored-By: Classic298 <27028174+Classic298@users.noreply.github.com> --- backend/open_webui/utils/json_codec.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/json_codec.py b/backend/open_webui/utils/json_codec.py index 141194fb92..41185e2514 100644 --- a/backend/open_webui/utils/json_codec.py +++ b/backend/open_webui/utils/json_codec.py @@ -11,7 +11,6 @@ from __future__ import annotations import json as stdlib_json from engineio import json as engineio_json - from open_webui.env import ENABLE_ORJSON if ENABLE_ORJSON: @@ -34,6 +33,9 @@ if ENABLE_ORJSON: @staticmethod def dumps(obj, *args, **kwargs): + # orjson can't honor stdlib json options; compact separators are its default. + if args or (kwargs and kwargs != {'separators': (',', ':')}): + return engineio_json.dumps(obj, *args, **kwargs) try: serialized = orjson.dumps(obj).decode('utf-8') except (TypeError, ValueError): @@ -44,6 +46,8 @@ if ENABLE_ORJSON: @staticmethod def loads(s, *args, **kwargs): + if args or kwargs: + return engineio_json.loads(s, *args, **kwargs) try: return orjson.loads(s) except (TypeError, ValueError):