{"record":{"id":"89f1cf5fa053f437","repo":"alibaba/spring-ai-alibaba","slug":"language-not-recognized-in-code-execution-languag-89f1cf","errorCode":null,"errorMessage":"Language not recognized in code execution:<language>","messagePattern":"Language not recognized in code execution:<language>","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/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-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/utils/CodeUtils.java#L13-L46","documentation":"CodeUtils.getExecutableForLanguage maps a language string to the interpreter executable and throws a checked Exception 'Language not recognized in code execution:<language>' for any language outside its switch (python/python3, shell/bash/sh/powershell, nodejs, java).","triggerScenarios":"Calling getExecutableForLanguage with values like 'javascript', 'py', 'python2', 'golang', or any LLM-emitted language tag not in the supported set.","commonSituations":"Model emits 'javascript' but the framework expects 'nodejs'; user config uses 'powershell' expecting Windows PowerShell when only sh is used; unsupported languages like go/rust passed programmatically.","solutions":["Use a supported language string: python3/python, shell/bash/sh/powershell, nodejs, or java.","Pre-normalize aliases ('js'/'javascript' -> 'nodejs') before calling.","Catch the Exception and reject the code block upstream with a helpful message.","Extend the switch / contribute a new mapping if the language must be supported."],"exampleFix":"// before\nString exe = CodeUtils.getExecutableForLanguage(\"javascript\"); // throws\n// after\nString lang = \"javascript\".equalsIgnoreCase(lang) ? \"nodejs\" : lang;\nString exe = CodeUtils.getExecutableForLanguage(lang);","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"python3\",\"python\",\"shell\",\"bash\",\"sh\",\"powershell\",\"nodejs\",\"java\");\nif (language == null || !allowed.contains(language.trim().toLowerCase())) {\n    throw new IllegalArgumentException(\"Unsupported language: \" + language);\n}","typeGuard":"boolean isSupportedLanguage(String lang) {\n    return lang != null && Set.of(\"python3\",\"python\",\"shell\",\"bash\",\"sh\",\"powershell\",\"nodejs\",\"java\").contains(lang.trim().toLowerCase());\n}","tryCatchPattern":"try {\n    exe = CodeUtils.getExecutableForLanguage(language);\n} catch (Exception e) {\n    throw new IllegalStateException(\"Cannot execute code: \" + e.getMessage() + \" — use python/python3/shell/bash/sh/powershell/nodejs/java\");\n}","preventionTips":["Constrain the LLM prompt to emit only supported language tags","Map aliases (javascript -> nodejs) at the ingestion layer","Validate language config at node-construction time"],"tags":["language-mapping","switch","code-execution","unsupported-value"],"backgroundTag":"unsupported-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"}