From 2634cfc06fd7ef15ec98dbee63191d79df7a7dc3 Mon Sep 17 00:00:00 2001 From: JiangNan <1394485448@qq.com> Date: Mon, 9 Mar 2026 11:09:47 +0800 Subject: [PATCH] Fix: undefined variable and wrong method name in agent components (#13462) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This PR fixes two runtime bugs in agent components: **Bug 1: `agent/component/invoke.py` — `NameError` in POST + `clean_html` path** The POST method's `clean_html` branch uses the variable `sections` without ever defining it. Both the GET and PUT branches correctly call `sections = HtmlParser()(None, response.content)` before referencing `sections`, but this line was missing from the POST branch (copy-paste omission). This causes a `NameError` whenever a user configures an Invoke component with `method="post"` and `clean_html=True`. **Bug 2: `agent/component/data_operations.py` — `AttributeError` in `_recursive_eval`** The `_recursive_eval` method recursively calls `self.recursive_eval()` (without the leading underscore) instead of `self._recursive_eval()`. Since the method is defined as `_recursive_eval`, this causes an `AttributeError` at runtime when the `literal_eval` operation processes nested dicts or lists. ## Test plan - [ ] Configure an Invoke node with `method=post` and `clean_html=True`, verify HTML is parsed correctly without `NameError` - [ ] Configure a DataOperations node with `operations=literal_eval` on nested data, verify no `AttributeError` --------- Signed-off-by: JiangNan <1394485448@qq.com> --- agent/component/data_operations.py | 4 ++-- agent/component/invoke.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/agent/component/data_operations.py b/agent/component/data_operations.py index cddd20996..60e65f881 100644 --- a/agent/component/data_operations.py +++ b/agent/component/data_operations.py @@ -94,9 +94,9 @@ class DataOperations(ComponentBase,ABC): def _recursive_eval(self, data): if isinstance(data, dict): - return {k: self.recursive_eval(v) for k, v in data.items()} + return {k: self._recursive_eval(v) for k, v in data.items()} if isinstance(data, list): - return [self.recursive_eval(item) for item in data] + return [self._recursive_eval(item) for item in data] if isinstance(data, str): try: if ( diff --git a/agent/component/invoke.py b/agent/component/invoke.py index 61ebe2b39..c24c91b16 100644 --- a/agent/component/invoke.py +++ b/agent/component/invoke.py @@ -121,6 +121,7 @@ class Invoke(ComponentBase, ABC): else: response = requests.post(url=url, data=args, headers=headers, proxies=proxies, timeout=self._param.timeout) if self._param.clean_html: + sections = HtmlParser()(None, response.content) self.set_output("result", "\n".join(sections)) else: self.set_output("result", response.text)