{"record":{"id":"750c5c80113c9688","repo":"alibaba/spring-ai-alibaba","slug":"no-enum-constant-com-alibaba-cloud-ai-graph-node-c","errorCode":null,"errorMessage":"No enum constant com.alibaba.cloud.ai.graph.node.code.entity.CodeLanguage.<value>","messagePattern":"No enum constant com\\.alibaba\\.cloud\\.ai\\.graph\\.node\\.code\\.entity\\.CodeLanguage\\.<value>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/code/entity/CodeLanguage.java","lineNumber":46,"sourceCode":"\tCodeLanguage(String value) {\n\t\tthis.value = value;\n\t}\n\n\tpublic String getValue() {\n\t\treturn value;\n\t}\n\n\t// Optionally, you can add a method to find an enum constant by its string value\n\tpublic static CodeLanguage fromValue(String value) {\n\t\tif (value == null || value.trim().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid code language provided\");\n\t\t}\n\t\tfor (CodeLanguage lang : values()) {\n\t\t\tif (lang.getValue().equalsIgnoreCase(value)) {\n\t\t\t\treturn lang;\n\t\t\t}\n\t\t}\n\t\tthrow new IllegalArgumentException(\"No enum constant \" + CodeLanguage.class.getName() + \".\" + value);\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn this.value;\n\t}\n\n}\n","sourceCodeStart":28,"sourceCodeEnd":55,"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/node/code/entity/CodeLanguage.java#L28-L55","documentation":"CodeLanguage.fromValue throws IllegalArgumentException('No enum constant ...CodeLanguage.<value>') when the string is non-blank but matches no known language value (case-insensitively). The full enum class name plus offending value is embedded in the message.","triggerScenarios":"Calling CodeLanguage.fromValue(\"py\") or \"javascript\" or \"Python3.\" — any alias not exactly equal (ignoring case) to a registered value like python/python3/shell/bash/nodejs/java.","commonSituations":"Users writing common aliases ('js', 'python3.x', 'powershell', 'golang') in config; LLM emitting 'javascript' for a 'nodejs'-only enum; copy-pasting language names with trailing whitespace/quotes.","solutions":["Check the supported values via CodeLanguage.values() and use an exact registered one (python/python3/shell/bash/nodejs/java etc.).","Normalize/trim the input string before conversion.","Add a mapping layer for common aliases (js -> nodejs) before calling fromValue.","Catch IllegalArgumentException and fall back to a default language."],"exampleFix":"// before\nCodeLanguage lang = CodeLanguage.fromValue(\"javascript\"); // IllegalArgumentException\n// after\nString language = \"javascript\".trim();\nif (language.equalsIgnoreCase(\"js\") || language.equalsIgnoreCase(\"javascript\")) language = \"nodejs\";\nCodeLanguage lang = CodeLanguage.fromValue(language);","handlingStrategy":"validation","validationCode":"Set<String> supported = Arrays.stream(CodeLanguage.values()).map(CodeLanguage::getValue).collect(Collectors.toSet());\nif (!supported.contains(rawLanguage.trim().toLowerCase())) {\n    throw new IllegalArgumentException(\"Unsupported language: \" + rawLanguage + \", supported: \" + supported);\n}","typeGuard":"boolean isKnownCodeLanguage(String lang) {\n    if (lang == null) return false;\n    return Arrays.stream(CodeLanguage.values()).anyMatch(l -> l.getValue().equalsIgnoreCase(lang.trim()));\n}","tryCatchPattern":"try {\n    return CodeLanguage.fromValue(rawLanguage);\n} catch (IllegalArgumentException e) {\n    log.error(\"Unknown code language '{}' — must be one of the CodeLanguage values\", rawLanguage);\n    throw new IllegalArgumentException(\"Unsupported language: \" + rawLanguage, e);\n}","preventionTips":["Print CodeLanguage.values() in docs/config samples so users know valid strings","Normalize aliases (js -> nodejs, py -> python) before conversion","Trim and lowercase language strings read from config or LLM output"],"tags":["enum","invalid-value","code-execution","argument-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"}