{"record":{"id":"ab5de0729818d80a","repo":"apache/dolphinscheduler","slug":"environment-name-is-null","errorCode":"ENVIRONMENT_NAME_IS_NULL","errorMessage":"Status.ENVIRONMENT_NAME_IS_NULL","messagePattern":"Status\\.ENVIRONMENT_NAME_IS_NULL","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java","lineNumber":396,"sourceCode":"                relation.setUpdateTime(new Date());\n                relation.setCreateTime(new Date());\n                relation.setOperator(loginUser.getId());\n                relationMapper.insert(relation);\n            }\n        });\n        return env;\n    }\n\n    /**\n     * verify environment name\n     *\n     * @param environmentName environment name\n     */\n    @Override\n    public void verifyEnvironment(String environmentName) {\n        if (StringUtils.isEmpty(environmentName)) {\n            log.warn(\"parameter environment name is empty.\");\n            throw new ServiceException(Status.ENVIRONMENT_NAME_IS_NULL);\n        }\n\n        Environment environment = environmentMapper.queryByEnvironmentName(environmentName);\n        if (environment != null) {\n            log.warn(\"Environment with the same name already exist, name:{}.\", environment.getName());\n            throw new ServiceException(Status.ENVIRONMENT_NAME_EXISTS, environmentName);\n        }\n    }\n\n    private void checkUsedEnvironmentWorkerGroupRelation(Set<String> deleteKeySet,\n                                                         String environmentName, Long environmentCode) {\n        for (String workerGroup : deleteKeySet) {\n            List<TaskDefinition> taskDefinitionList =\n                    taskDefinitionDao.queryByEnvironmentCodeAndWorkerGroup(environmentCode, workerGroup);\n\n            if (Objects.nonNull(taskDefinitionList) && taskDefinitionList.size() != 0) {\n                Set<String> collect =\n                        taskDefinitionList.stream().map(TaskDefinition::getName).collect(Collectors.toSet());","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java#L378-L414","documentation":"Thrown in EnvironmentServiceImpl.verifyEnvironment when the environmentName parameter is empty or null. It is an input-validation guard in the name-verification path; an empty name can never identify a valid environment, so the request is rejected immediately.","triggerScenarios":"Calling verifyEnvironment(null) or verifyEnvironment(\"\") — typically reached from createEnvironment when the request body omitted the name field.","commonSituations":"Client form submissions missing the name field; scripts that build JSON payloads with unfilled variables (null interpolated); API consumers using the wrong request parameter name.","solutions":["Supply a non-empty environmentName in the request","Validate the name field client-side before calling the API","Fix variable interpolation in scripts so the name isn't empty","Check that the request body field name matches 'environmentName'/'name' expected by the endpoint"],"exampleFix":"// before\nenvironmentService.verifyEnvironment(params.get(\"envName\")); // null when key missing\n// after\nString envName = params.get(\"envName\");\nif (envName == null || envName.isEmpty()) {\n    throw new IllegalArgumentException(\"environmentName is required\");\n}\nenvironmentService.verifyEnvironment(envName);","handlingStrategy":"validation","validationCode":"if (environmentName == null || environmentName.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"environmentName must be non-empty\");\n}","typeGuard":"boolean isValidName(String s) { return s != null && !s.trim().isEmpty(); }","tryCatchPattern":"try {\n    environmentService.verifyEnvironment(name);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.ENVIRONMENT_NAME_IS_NULL.getCode()) {\n        // prompt user for a name\n    } else { throw e; }\n}","preventionTips":["Mark name as required in forms and API clients","Validate payloads before sending (non-null, non-blank)","Beware unset variables in scripts producing empty strings"],"tags":["dolphinscheduler","environment","missing-parameter","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}