{"record":{"id":"87ef5e71767fad46","repo":"alibaba/spring-ai-alibaba","slug":"error-87ef5e","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":150,"sourceCode":"        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);\n\n        EvaluatorDebugResult result = evaluatorTest(request);\n\n        return result;\n    }\n\n\n    /**\n     * 调试模型调用\n     */\n    public EvaluatorDebugResult evaluatorTest(EvaluatorTestRequest request) {\n        ChatSession session = chatSessionService.createEvaluatorSession(request.getPrompt(), request.getVariables(), request.getModelConfig());","sourceCodeStart":132,"sourceCodeEnd":168,"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#L132-L168","documentation":"Thrown by EvaluatorServiceImpl.deleteById when evaluatorMapper.deleteById(id) returns 0 rows affected, meaning no evaluator with the given ID exists in the database (or it was already deleted). It is a generic RuntimeException wrapping a 'no rows deleted' outcome rather than a typed not-found exception.","triggerScenarios":"Calling DELETE /evaluator/{id} (or service.deleteById) with an ID that does not exist, an already-deleted evaluator, or an ID belonging to another tenant/database.","commonSituations":"Stale UI state deleting an evaluator removed elsewhere; double-clicking a delete button so the second call hits an already-deleted row; passing a string/truncated ID; wrong database profile (dev vs prod) so the row never existed there.","solutions":["Verify the evaluator ID exists (evaluatorMapper.selectById) before deleting and return a typed 404 if absent","Check result==0 and throw a domain exception like EvaluatorNotFoundException so the controller maps it to 404 instead of 500","Confirm the client is pointed at the environment where the evaluator actually exists","Change deleteById to return the affected count so callers can treat 0 as idempotent success"],"exampleFix":"// before\nif (result > 0) {\n    log.info(\"评估器删除成功: {}\", id);\n} else {\n    throw new RuntimeException(\"删除评估器失败\");\n}\n// after\nEvaluatorDO existing = evaluatorMapper.selectById(id);\nif (existing == null) {\n    throw new EvaluatorNotFoundException(id); // mapped to 404\n}\nevaluatorMapper.deleteById(id);","handlingStrategy":"validation","validationCode":"if (id == null || id <= 0) throw new IllegalArgumentException(\"evaluator id required\");\nif (evaluatorService.getById(id) == null) throw new EvaluatorNotFoundException(id);","typeGuard":"boolean evaluatorExists(Long id) { return id != null && id > 0 && evaluatorService.getById(id) != null; }","tryCatchPattern":"try { evaluatorService.deleteById(id); } catch (RuntimeException e) { /* map to 404 */ }","preventionTips":["Check existence before delete","Treat delete of missing rows as idempotent in UI flows","Guard against double-submit on delete buttons"],"tags":["database","delete","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"}