From 7f237fee16feabe059a0206671574c4334618221 Mon Sep 17 00:00:00 2001 From: xiaoyu0701 <67354501+xiaoyu0701@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:48:10 +0800 Subject: [PATCH] Fix:HTTPs component re.error: bad escape \u (#9480) ### What problem does this PR solve? When calling HTTP to request data, if the JSON string returned by the interface contains an unasked back slash like '\u', Python's RE module will escape 'u' as Unicode, but there is no valid 4-digit hexadecimal number at the end, so it will directly report an error. Error: re. error: bad escape \ u at position 26 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/agent/component/base.py b/agent/component/base.py index f8f54c004..4cba409ca 100644 --- a/agent/component/base.py +++ b/agent/component/base.py @@ -529,8 +529,12 @@ class ComponentBase(ABC): @staticmethod def string_format(content: str, kv: dict[str, str]) -> str: for n, v in kv.items(): + def repl(_match, val=v): + return str(val) if val is not None else "" content = re.sub( - r"\{%s\}" % re.escape(n), v, content + r"\{%s\}" % re.escape(n), + repl, + content ) return content