alibaba/spring-ai-alibaba · warning
Invalid experiment status: {}
Error message
Invalid experiment status: {} What it means
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.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/ExperimentServiceImpl.java:109
log.info("实验创建成功: {}", experimentDO.getId());
// 异步启动实验执行
startExperimentExecution(experimentDO);
return Experiment.fromDO(experimentDO);
}
@Override
public PageResult<Experiment> list(ExperimentListRequest request) {
log.info("查询实验列表: {}", request);
ExperimentStatus status = null;
if (StringUtils.hasText(request.getStatus())) {
try {
status = ExperimentStatus.fromCode(request.getStatus());
} catch (IllegalArgumentException e) {
log.warn("Invalid experiment status: {}", request.getStatus());
}
}
// 计算偏移量
long offset = (request.getPageNumber() - 1L) * request.getPageSize();
// 查询数据
List<ExperimentDO> experimentDOList = experimentMapper.selectList(request.getName(), status, offset, request.getPageSize());
// 获取总数
int totalCount = experimentMapper.count(request.getName(), status);
return new PageResult<>(
(long) totalCount,
(long) request.getPageNumber(),
(long) request.getPageSize(),
experimentDOList.stream()
.map(Experiment::fromDO)View on GitHub (pinned to f82da0b50f)
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.
Example fix
// before
request.setStatus("Completed"); // ignored: not a valid code
// after
String code = ExperimentStatus.COMPLETED.getCode();
request.setStatus(code); // or validate: ExperimentStatus.fromCode(raw.trim().toUpperCase()) Defensive patterns
Strategy: validation
Validate before calling
public static void validateStatus(String raw) {
if (StringUtils.hasText(raw)) {
ExperimentStatus.fromCode(raw.trim()); // throws IllegalArgumentException if invalid
}
} Try / catch
try {
results = experimentService.list(request);
} catch (IllegalArgumentException e) {
// reject the request instead of silently ignoring the filter
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Invalid experiment status");
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- 未找到ID为{}的实验
- 实验不存在: {}
- 实验 {} 状态为 {},无法停止
- 数据集为空,实验完成: {}
- 获取数据集版本信息失败: experimentId={}, datasetVersionId={}
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/f3f5d75baa83c384.
Report an issue: GitHub.