From 48bacd01cc6087b3954bc92758c942bec239a422 Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:50:57 +0800 Subject: [PATCH] fix: incorrect tool name (#2489) --- api/core/tools/utils/parser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/core/tools/utils/parser.py b/api/core/tools/utils/parser.py index 68a8adc11d..af0518d69e 100644 --- a/api/core/tools/utils/parser.py +++ b/api/core/tools/utils/parser.py @@ -115,7 +115,12 @@ class ApiBasedToolSchemaParser: # check if there is a operation id, use $path_$method as operation id if not if 'operationId' not in interface['operation']: - interface['operation']['operationId'] = f'{interface["path"]}_{interface["method"]}' + # remove special characters like / to ensure the operation id is valid ^[a-zA-Z0-9_-]{1,64}$ + path = interface['path'] + if interface['path'].startswith('/'): + path = interface['path'][1:] + path = path.replace('/', '_') + interface['operation']['operationId'] = f'{path}_{interface["method"]}' bundles.append(ApiBasedToolBundle( server_url=server_url + interface['path'],