fix: raise clear error on unsupported language in execute_code#38448
Merged
crazywoola merged 5 commits intoJul 8, 2026
Merged
Conversation
execute_code() uses code_language_to_running_language.get(language) which returns None for unsupported languages. This None gets serialized as null in the sandbox request, producing a cryptic remote error instead of a clear local failure. Add an explicit guard that raises CodeExecutionError with an 'Unsupported language' message before calling the sandbox service. This matches the pattern already used in execute_workflow_code_template which has the same guard for unsupported template transformers. Fixes langgenius#37874
Contributor
Pyrefly Type Coverage
|
crazywoola
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #37874
Problem
CodeExecutor.execute_code()mapsCodeLanguageto sandbox runtime viacode_language_to_running_language.get(language). When the language is unsupported,.get()returnsNoneand the request is sent with"language": null, which leads to a cryptic remote sandbox error instead of a clear local failure.execute_workflow_code_template()already fails fast withCodeExecutionError("Unsupported language ...")when no transformer exists, butexecute_codeitself has no equivalent guard.Fix
Add an explicit guard at the start of
execute_code():Then use the validated
running_languagein the sandbox request data.Changes
api/core/helper/code_executor/code_executor.py: Add unsupported language guard (5 lines added, 1 changed)Mathes the existing pattern in
execute_workflow_code_template(line 145-146).