fix: raise clear error on unsupported language in execute_code (#38448)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
i晟 2026-07-08 14:20:10 +08:00 committed by GitHub
parent 10cf9be3c7
commit af4538e942
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,12 +74,16 @@ class CodeExecutor:
:param code: code
:return:
"""
running_language = cls.code_language_to_running_language.get(language)
if running_language is None:
raise CodeExecutionError(f"Unsupported language {language}")
url = code_execution_endpoint_url / "v1" / "sandbox" / "run"
headers = {"X-Api-Key": dify_config.CODE_EXECUTION_API_KEY}
data = {
"language": cls.code_language_to_running_language.get(language),
"language": running_language,
"code": code,
"preload": preload,
"enable_network": True,