{"record":{"id":"f3f5d75baa83c384","repo":"alibaba/spring-ai-alibaba","slug":"invalid-experiment-status","errorCode":null,"errorMessage":"Invalid experiment status: {}","messagePattern":"Invalid experiment status: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ExperimentServiceImpl.java","lineNumber":109,"sourceCode":"        log.info(\"实验创建成功: {}\", experimentDO.getId());\n        \n        // 异步启动实验执行\n        startExperimentExecution(experimentDO);\n        \n        return Experiment.fromDO(experimentDO);\n    }\n\n    @Override\n    public PageResult<Experiment> list(ExperimentListRequest request) {\n        log.info(\"查询实验列表: {}\", request);\n\n\n        ExperimentStatus status = null;\n        if (StringUtils.hasText(request.getStatus())) {\n            try {\n                status = ExperimentStatus.fromCode(request.getStatus());\n            } catch (IllegalArgumentException e) {\n                log.warn(\"Invalid experiment status: {}\", request.getStatus());\n            }\n        }\n        \n        // 计算偏移量\n        long offset = (request.getPageNumber() - 1L) * request.getPageSize();\n        \n        // 查询数据\n        List<ExperimentDO> experimentDOList = experimentMapper.selectList(request.getName(), status, offset, request.getPageSize());\n\n        // 获取总数\n        int totalCount = experimentMapper.count(request.getName(), status);\n\n        return new PageResult<>(\n                (long) totalCount,\n                (long) request.getPageNumber(),\n                (long) request.getPageSize(),\n                experimentDOList.stream()\n                        .map(Experiment::fromDO)","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ExperimentServiceImpl.java#L91-L127","documentation":"ExperimentServiceImpl.list logs this warning when the request's status string cannot be converted to an ExperimentStatus via ExperimentStatus.fromCode. Instead of failing the request, the code catches the IllegalArgumentException, logs the invalid value, and continues the query with status == null (i.e., the status filter is silently ignored), which can return more rows than the caller expected.","triggerScenarios":"Calling experimentService.list(request) with request.setStatus(\"RUNNIG\") or any string that is not a valid ExperimentStatus code (e.g., free-text like \"running \" with whitespace, wrong case, or an old enum code removed in an upgrade).","commonSituations":"Frontend sends a human-readable status label instead of the enum code; API version change renamed status codes; user typo in a query param; locale-specific status strings.","solutions":["Validate the status string against ExperimentStatus codes on the client/server before calling list().","Trim and normalize (uppercase) the status string before mapping.","Fix the caller to send the exact code returned by ExperimentStatus.getCode().","If you need a hard failure instead of silent filtering, throw in the catch block rather than logging."],"exampleFix":"// before\nrequest.setStatus(\"Completed\"); // ignored: not a valid code\n\n// after\nString code = ExperimentStatus.COMPLETED.getCode();\nrequest.setStatus(code); // or validate: ExperimentStatus.fromCode(raw.trim().toUpperCase())","handlingStrategy":"validation","validationCode":"public static void validateStatus(String raw) {\n    if (StringUtils.hasText(raw)) {\n        ExperimentStatus.fromCode(raw.trim()); // throws IllegalArgumentException if invalid\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    results = experimentService.list(request);\n} catch (IllegalArgumentException e) {\n    // reject the request instead of silently ignoring the filter\n    throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Invalid experiment status\");\n}","preventionTips":["Always send status values produced by ExperimentStatus.getCode(), never human-readable labels.","Trim and uppercase status input at the API boundary.","Keep frontend enum constants in sync with backend ExperimentStatus on upgrades.","Add a request-level validator (@Pattern or custom) for status fields."],"tags":["java","spring","enum","validation","experiment"],"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"}