{"record":{"id":"01d2b5fffdc396d1","repo":"alibaba/spring-ai-alibaba","slug":"error-01d2b5","errorCode":null,"errorMessage":"更新评估器失败","messagePattern":"更新评估器失败","errorType":"exception","errorClass":"RuntimeException","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/EvaluatorServiceImpl.java","lineNumber":138,"sourceCode":"    @Override\n    public Evaluator update(EvaluatorUpdateRequest request) {\n        log.info(\"更新评估器: {}\", request);\n\n        // 构建DO对象\n        EvaluatorDO evaluatorDO = EvaluatorDO.builder()\n                .id(request.getId())\n                .name(request.getName())\n                .description(request.getDescription())\n                .build();\n\n        // 更新数据库\n        int result = evaluatorMapper.update(evaluatorDO);\n        if (result > 0) {\n            log.info(\"评估器更新成功: {}\", request.getId());\n            // 重新查询获取最新数据\n            return Evaluator.fromDO(evaluatorMapper.selectById(request.getId()));\n        } else {\n            throw new RuntimeException(\"更新评估器失败\");\n        }\n    }\n\n    @Override\n    public void deleteById(Long id) {\n        log.info(\"删除评估器: {}\", id);\n\n        int result = evaluatorMapper.deleteById(id);\n        if (result > 0) {\n            log.info(\"评估器删除成功: {}\", id);\n        } else {\n            throw new RuntimeException(\"删除评估器失败\");\n        }\n    }\n\n    @Override\n    public EvaluatorDebugResult debug(EvaluatorTestRequest request) {\n        log.info(\"调试评估器: {}\", request);","sourceCodeStart":120,"sourceCodeEnd":156,"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/EvaluatorServiceImpl.java#L120-L156","documentation":"EvaluatorServiceImpl.update() calls evaluatorMapper.update(evaluatorDO) and throws RuntimeException(\"更新评估器失败\") (\"failed to update evaluator\") when the affected-row count is <= 0. The UPDATE matched no rows, meaning no evaluator exists with request.getId() (or the row was changed concurrently so the WHERE clause no longer matches).","triggerScenarios":"Updating an evaluator with an id that was never created or already deleted; a concurrent delete removed the row between load and update; an update SQL with optimistic-lock/version column that mismatches.","commonSituations":"Editing an evaluator in a UI tab left open while another user deleted it; stale IDs after switching environments; PUT requests replayed after the evaluator was removed.","solutions":["Confirm the evaluator exists: call getById/selectById(request.getId()) before updating.","Refresh the evaluator list and retry with a valid id.","If optimistic locking is in play, re-read the current row, reapply changes, and retry."],"exampleFix":"// before\nrequest.setId(deletedEvaluatorId);\nservice.update(request); // RuntimeException\n// after\nif (service.getById(request.getId()) == null) {\n    throw new EvaluatorNotFoundException(request.getId());\n}\nservice.update(request);","handlingStrategy":"validation","validationCode":"if (service.getById(request.getId()) == null) {\n    throw new EvaluatorNotFoundException(request.getId());\n}","typeGuard":"boolean evaluatorExists(Long id) { return id != null && service.getById(id) != null; }","tryCatchPattern":"try {\n    return service.update(request);\n} catch (RuntimeException e) {\n    throw new ResponseStatusException(HttpStatus.NOT_FOUND,\n        \"Evaluator \" + request.getId() + \" no longer exists; refresh and retry\");\n}","preventionTips":["Re-fetch the evaluator before saving edits, especially in long-lived UI sessions.","On 404-style failure, reload the evaluator list rather than retrying blindly.","Use optimistic locking / version columns if concurrent edits are expected."],"tags":["database","update-failed","evaluator","record-not-found"],"backgroundTag":"database-write-failed","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"}