{"record":{"id":"6b81f931baed87ce","repo":"alibaba/spring-ai-alibaba","slug":"language-not-recognized-in-code-execution-languag","errorCode":null,"errorMessage":"Language not recognized in code execution:{language}","messagePattern":"Language not recognized in code execution:(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/utils/CodeUtils.java","lineNumber":31,"sourceCode":" * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.alibaba.cloud.ai.graph.utils;\n\n/**\n * @author HeYQ\n * @since 2025-06-01 20:35\n */\n\npublic class CodeUtils {\n\n\tpublic static String getExecutableForLanguage(String language) throws Exception {\n\t\treturn switch (language) {\n\t\t\tcase \"python3\", \"python\" -> language;\n\t\t\tcase \"shell\", \"bash\", \"sh\", \"powershell\" -> \"sh\";\n\t\t\tcase \"nodejs\" -> \"node\";\n\t\t\tcase \"java\" -> \"java\";\n\t\t\tdefault -> throw new Exception(\"Language not recognized in code execution:\" + language);\n\t\t};\n\t}\n\n\tpublic static String getFileExtForLanguage(String language) throws Exception {\n\t\treturn switch (language) {\n\t\t\tcase \"python3\", \"python\" -> \"py\";\n\t\t\tcase \"shell\", \"bash\", \"sh\", \"powershell\" -> \"sh\";\n\t\t\tcase \"nodejs\" -> \"js\";\n\t\t\tcase \"java\" -> \"java\";\n\t\t\tdefault -> throw new Exception(\"Language not recognized in code execution:\" + language);\n\t\t};\n\t}\n\n}\n","sourceCodeStart":13,"sourceCodeEnd":46,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/utils/CodeUtils.java#L13-L46","documentation":"CodeUtils.getExecutableForLanguage maps a supported language name to its executable command (python, sh, node, java). Any language string outside the fixed switch set throws a plain Exception with the unrecognized language appended to the message.","triggerScenarios":"Calling getExecutableForLanguage with any string not exactly equal to python3/python/shell/bash/sh/powershell/nodejs/java — e.g. 'py', 'javascript', 'Python' (case-sensitive), 'node', 'pwsh'.","commonSituations":"Model/LLM emits a language name in slightly different casing or an alias ('javascript' instead of 'nodejs'), user config uses a wrong language identifier in a code-execution node, or a typo in workflow configuration.","solutions":["Use one of the exact supported identifiers: python3, python, shell, bash, sh, powershell, nodejs, java.","Normalize the language string to lowercase and trim whitespace before calling.","Map aliases yourself before the call (e.g. javascript -> nodejs, py -> python).","Extend the switch in CodeUtils if a new language must be supported upstream."],"exampleFix":"// before\nString exe = CodeUtils.getExecutableForLanguage(lang); // lang = \"JavaScript\"\n// after\nString normalized = lang == null ? \"\" : lang.trim().toLowerCase();\nif (normalized.equals(\"javascript\")) { normalized = \"nodejs\"; }\nString exe = CodeUtils.getExecutableForLanguage(normalized);","handlingStrategy":"validation","validationCode":"private static final Set<String> SUPPORTED = Set.of(\"python3\",\"python\",\"shell\",\"bash\",\"sh\",\"powershell\",\"nodejs\",\"java\");\nboolean ok = lang != null && SUPPORTED.contains(lang.trim().toLowerCase());","typeGuard":"static boolean isSupportedLanguage(String lang) {\n    return lang != null && SUPPORTED_LANGUAGES.contains(lang.trim().toLowerCase());\n}","tryCatchPattern":"try {\n    String exe = CodeUtils.getExecutableForLanguage(lang);\n} catch (Exception e) {\n    throw new IllegalArgumentException(\"Unsupported language: \" + lang + \"; supported: python, shell, nodejs, java\");\n}","preventionTips":["Normalize language strings (trim + lowercase) from all inputs, especially LLM output.","Keep a whitelist constant mirroring CodeUtils' switch.","Map common aliases (javascript->nodejs, py->python) before calling.","Add unit tests covering every language identifier your workflows emit."],"tags":["code-execution","language-mapping","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}