{"record":{"id":"a30f650355f88c94","repo":"alibaba/spring-ai-alibaba","slug":"experiment-not-found","errorCode":null,"errorMessage":"Experiment not found: ","messagePattern":"Experiment not found: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","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":270,"sourceCode":"                (long) request.getPageNumber(),\n                (long) request.getPageSize(),\n                resultItems);\n\n    }\n\n    @Override\n    @Transactional\n    public Experiment stop(Long id) {\n        log.info(\"停止实验: {}\", id);\n        \n        if (id == null) {\n            throw new IllegalArgumentException(\"Experiment ID cannot be null\");\n        }\n        \n        // 获取实验信息\n        ExperimentDO experimentDO = experimentMapper.selectById(id);\n        if (experimentDO == null) {\n            throw new IllegalArgumentException(\"Experiment not found: \" + id);\n        }\n\n\n\n        // 检查实验状态\n        if (ExperimentStatus.COMPLETED.getCode().equals(experimentDO.getStatus()) ||\n            ExperimentStatus.FAILED.getCode().equals(experimentDO.getStatus()) ||\n            ExperimentStatus.STOPPED.getCode().equals(experimentDO.getStatus())) {\n            log.warn(\"实验 {} 状态为 {}，无法停止\", id, experimentDO.getStatus());\n            return Experiment.fromDO(experimentDO);\n        }\n\n\n        \n        // 更新实验状态为已停止\n        experimentDO.setStatus(String.valueOf(ExperimentStatus.STOPPED));\n        experimentDO.setUpdateTime(LocalDateTime.now());\n        ","sourceCodeStart":252,"sourceCodeEnd":288,"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#L252-L288","documentation":"Thrown by ExperimentServiceImpl.stop when experimentMapper.selectById(id) returns null: no experiment exists with the given ID, so there is nothing to stop. It is an IllegalArgumentException carrying the offending ID in the message.","triggerScenarios":"Stopping an experiment ID that was deleted, never created, already completed and purged, or exists only in a different environment/datasource.","commonSituations":"Double-stop: the second request races with cleanup or the record was removed; stale experiment list in the UI; switching between dev and prod databases; typo'd or truncated ID.","solutions":["Verify the experiment ID exists (getById) before calling stop","Catch the IllegalArgumentException and surface 404 to the client instead of 500","Confirm client and server point at the same environment/database","Handle concurrent-stop races by treating not-found as idempotent success"],"exampleFix":"// before\nif (experimentDO == null) {\n    throw new IllegalArgumentException(\"Experiment not found: \" + id);\n}\n// after\nif (experimentDO == null) {\n    throw new ExperimentNotFoundException(id); // mapped to 404 by exception handler\n}","handlingStrategy":"validation","validationCode":"if (experimentService.getById(id) == null) throw new ExperimentNotFoundException(id);","typeGuard":"boolean experimentExists(Long id) { return id != null && experimentService.getById(id) != null; }","tryCatchPattern":"try { experimentService.stop(id); } catch (IllegalArgumentException e) { log.warn(\"Stop for missing experiment {}\", id); /* treat as idempotent success or 404 */ }","preventionTips":["Refresh experiment lists after external changes","Distinguish 'already finished/stopped' from 'never existed'","Keep client and server on the same environment/datasource"],"tags":["not-found","experiment","stop"],"backgroundTag":"entity-not-found","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"}