RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
fix: substitute UserFillUp tips placeholders literally to avoid re.error (#17321)
rsnetworkinginca7421bfd607b
diff --git a/agent/component/fillup.py b/agent/component/fillup.pyindex ab2a3f6ed6..423110674f 100644--- a/agent/component/fillup.py+++ b/agent/component/fillup.py@@ -14,7 +14,6 @@# limitations under the License.#import json-import refrom functools import partialfrom agent.component.base import ComponentParamBase, ComponentBase@@ -81,7 +80,7 @@ class UserFillUp(ComponentBase):ans = vif not ans:ans = ""- content = re.sub(r"\{%s\}" % k, ans, content)+ content = content.replace("{%s}" % k, ans)self.set_output("tips", content)layout_recognize = self._param.layout_recognize or Nonediff --git a/test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py b/test/testcases/test_web_api/test_canvas_app/test_fillup_unit.pyindex 9b812d9fcd..9b96486363 100644--- a/test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py+++ b/test/testcases/test_web_api/test_canvas_app/test_fillup_unit.py@@ -208,3 +208,26 @@ def test_user_fillup_reentry_keeps_optional_file_value(monkeypatch):assert component._param.inputs["text"]["value"] is Noneassert component._param.inputs["doc"]["value"] == ["file-id"]+++def test_user_fillup_tips_substitution_is_literal_for_regex_like_values(monkeypatch):+ # A form value containing a regex backreference-like sequence (e.g. a Windows+ # path such as "C:\\1files") must be inserted into the tips template verbatim.+ # It must not raise "invalid group reference" nor be reinterpreted as a regex+ # replacement group.+ module = _load_fillup_module(monkeypatch)++ component = module.UserFillUp.__new__(module.UserFillUp)+ component._param = SimpleNamespace(+ enable_tips=True,+ tips="Path is {path}",+ layout_recognize="",+ inputs={},+ outputs={},+ )+ component.get_input_elements_from_text = lambda _text: {"path": {"value": r"C:\1files"}}++ component._invoke(inputs={})++ assert component._param.outputs["tips"]["value"] == r"Path is C:\1files"