alibaba/spring-ai-alibaba · error · IllegalArgumentException

评测集名称不能为空

Error message

评测集名称不能为空

What it means

Input validation failure in DatasetServiceImpl.create. The method requires a non-blank dataset name before persisting the new dataset; when DatasetCreateRequest.getName() is null, empty, or whitespace-only, IllegalArgumentException is thrown inside the @Transactional method, rolling back any partial writes. This is a client-side request problem: the caller must supply a name before retrying.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/DatasetServiceImpl.java:48

    private DatasetMapper datasetMapper;

    @Resource
    private DatasetVersionMapper datasetVersionMapper;




    private static final String INPUT_COLUMN_TYPE = "input";
    private static final String REFERENCE_OUTPUT_COLUMN_TYPE = "reference_output";


    @Override
    @Transactional
    public Dataset create(DatasetCreateRequest request) {
        log.info("创建评测集: {}", request);

        if (!StringUtils.hasText(request.getName())) {
            throw new IllegalArgumentException("评测集名称不能为空");
        }


        if (request == null || request.getColumnsConfig() == null ||
                !hasRequiredColumns(request.getColumnsConfig())) {
            throw new IllegalArgumentException("评测集列配置错误,必须包含input和reference_output两列");
        }

        DatasetDO datasetDO = DatasetDO.builder()
                .name(request.getName())
                .description(request.getDescription())
                .columnsConfig(JSONObject.toJSONString(request.getColumnsConfig()))
                .build();

        datasetMapper.insert(datasetDO);
        log.info("评测集创建成功: {}", datasetDO);
        return Dataset.fromDO(datasetDO);
    }

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Set a non-empty name on DatasetCreateRequest before calling create
  2. Add @NotBlank on the request DTO's name field for earlier, standardized validation
  3. Fix the JSON payload key so it matches the DTO field name
  4. Validate input in the controller with @Valid and return a 400

Example fix

// before
DatasetCreateRequest req = new DatasetCreateRequest();
req.setDescription("eval set");
datasetService.create(req);
// after
DatasetCreateRequest req = new DatasetCreateRequest();
req.setName("my-eval-set");
req.setDescription("eval set");
datasetService.create(req);
Defensive patterns

Strategy: validation

Validate before calling

if (request.getName() == null || request.getName().isBlank()) { throw new IllegalArgumentException("name is required"); }

Type guard

boolean hasName(DatasetCreateRequest r) { return r != null && r.getName() != null && !r.getName().isBlank(); }

Try / catch

try { datasetService.create(req); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().body(e.getMessage()); }

Prevention

When it happens

Trigger: POSTing a DatasetCreateRequest with name omitted, empty string, or whitespace; JSON deserialization leaving name null due to a wrong field name in the payload.

Common situations: Front-end form allowing empty submit; API client sending "title" instead of "name"; automated scripts with partial payloads.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/a931a7a46e52716e. Report an issue: GitHub.