{"record":{"id":"70cc0bdb8647a6bb","repo":"alibaba/spring-ai-alibaba","slug":"either-language-or-code-must-be-provided","errorCode":null,"errorMessage":"Either language or code must be provided.","messagePattern":"Either language or code must be provided\\.","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/node/code/LocalCommandlineCodeExecutor.java","lineNumber":77,"sourceCode":"\t\t\t// \"bash\", \"shell\", \"sh\", \"python\"\n\t\t\tresult = executeCode(language, code, codeExecutionConfig);\n\t\t\tallLogs.append(\"\\n\").append(result.logs());\n\t\t\tif (result.exitCode() != 0) {\n\t\t\t\treturn new CodeExecutionResult(result.exitCode(), allLogs.toString());\n\t\t\t}\n\t\t}\n\t\treturn new CodeExecutionResult(0, allLogs.toString());\n\t}\n\n\t@Override\n\tpublic void restart() {\n\n\t\tlogger.warn(\"Restarting local command line code executor is not supported. No action is taken.\");\n\t}\n\n\tpublic CodeExecutionResult executeCode(String language, String code, CodeExecutionConfig config) throws Exception {\n\t\tif (Objects.isNull(language) || Objects.isNull(code)) {\n\t\t\tthrow new Exception(\"Either language or code must be provided.\");\n\t\t}\n\t\tString workDir = config.getWorkDir();\n\t\tString codeHash = DigestUtils.md5Hex(code);\n\t\tString fileExt = CodeUtils.getFileExtForLanguage(language);\n\t\tString filename = String.format(\"tmp_code_%s.%s\", codeHash, fileExt);\n\n\t\t// write the code string to a file specified by the filename.\n\t\tFileUtils.writeCodeToFile(workDir, filename, code);\n\n\t\t// Copy required JAR files to workDir if language is Java\n\t\tif (\"java\".equals(language)) {\n\t\t\tFileUtils.copyResourceJarToWorkDir(workDir);\n\t\t}\n\n\t\tCodeExecutionResult executionResult = executeCodeLocally(language, workDir, filename, config);\n\n\t\tFileUtils.deleteFile(workDir, filename);\n","sourceCodeStart":59,"sourceCodeEnd":95,"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/LocalCommandlineCodeExecutor.java#L59-L95","documentation":"LocalCommandlineCodeExecutor.executeCode throws a checked Exception when either the language or the code argument is null. The executor needs both to pick the interpreter and to materialize the code into a temp file under the work directory.","triggerScenarios":"Calling executeCode(language, code, config) with a null language, a null code string, or a code block whose fields were never populated (e.g. an LLM produced a code block missing the 'language' or 'code' key).","commonSituations":"An LLM response parsed into code blocks where the model omitted the language tag; programmatically building CodeExecutionBlock and forgetting to set code; passing a null map value from configuration.","solutions":["Validate language and code are non-null/non-blank before calling executeCode.","If blocks come from an LLM response, check parsing and require the model to output both fields (prompt or schema enforcement).","Wrap the call and surface a clearer message to the caller instead of the raw Exception."],"exampleFix":"// before\nexecutor.executeCode(language, code, config); // throws if either is null\n// after\nObjects.requireNonNull(language, \"language must not be null\");\nObjects.requireNonNull(code, \"code must not be null\");\nexecutor.executeCode(language, code, config);","handlingStrategy":"validation","validationCode":"if (language == null || language.isBlank()) throw new IllegalArgumentException(\"language is required\");\nif (code == null || code.isBlank()) throw new IllegalArgumentException(\"code is required\");","typeGuard":"boolean isExecutableBlock(String language, String code) {\n    return language != null && !language.isBlank() && code != null && !code.isBlank();\n}","tryCatchPattern":"try {\n    return executor.executeCode(language, code, config);\n} catch (Exception e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"language or code\")) {\n        return CodeExecutionResult.empty();\n    }\n    throw new RuntimeException(e);\n}","preventionTips":["Enforce schema validation on LLM-produced code blocks (language + code required)","Default missing language to a known value like 'python'","Reject empty code blocks at the workflow input boundary"],"tags":["null-check","code-execution","argument-validation"],"backgroundTag":"null-argument","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"}