alibaba/spring-ai-alibaba · error · RuntimeException

评估器版本不存在

Error message

评估器版本不存在

What it means

Thrown by EvaluatorVersionServiceImpl.update when selectById(request.getEvaluatorVersionId()) returns null — no evaluator version exists for the supplied ID. The service refuses to update a non-existent row and fails fast with this RuntimeException.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/service/impl/EvaluatorVersionServiceImpl.java:93

    }

    @Override
    public EvaluatorVersion getById(Long id) {
        log.info("查询评估器版本详情: {}", id);

        return EvaluatorVersion.fromDO(evaluatorVersionMapper.selectById(id));
    }

    @Override
    public EvaluatorVersion update(EvaluatorVersionUpdateRequest request) {
        log.info("更新评估器版本: {}", request.getEvaluatorVersionId());


        // 检查版本是否已存在及状态验证
        EvaluatorVersionDO exists = evaluatorVersionMapper.selectById(request.getEvaluatorVersionId());

        if (Objects.isNull(exists)){
            throw new RuntimeException("评估器版本不存在");
        }

        evaluatorVersionMapper.update(request.getEvaluatorVersionId(), request.getDescription(), request.getStatus());

        return getById(request.getEvaluatorVersionId());
    }
}

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Verify the evaluatorVersionId exists (GET list or getById) before updating
  2. Distinguish evaluatorId vs evaluatorVersionId in the request — update expects the version's ID
  3. Throw a typed EvaluatorVersionNotFoundException so the API returns 404 not 500
  4. Check you are connected to the environment where the version was created

Example fix

// before
if (Objects.isNull(exists)) {
    throw new RuntimeException("评估器版本不存在");
}
// after
if (Objects.isNull(exists)) {
    throw new EvaluatorVersionNotFoundException(request.getEvaluatorVersionId()); // -> 404
}
Defensive patterns

Strategy: validation

Validate before calling

if (request.getEvaluatorVersionId() == null) throw new IllegalArgumentException("evaluatorVersionId required");
if (evaluatorVersionService.getById(request.getEvaluatorVersionId()) == null) throw new EvaluatorVersionNotFoundException(request.getEvaluatorVersionId());

Type guard

boolean versionExists(Long id) { return id != null && evaluatorVersionService.getById(id) != null; }

Try / catch

try { return evaluatorVersionService.update(request); } catch (RuntimeException e) { return ResponseEntity.notFound().build(); }

Prevention

When it happens

Trigger: Calling the update API with an evaluatorVersionId that was deleted, never created, or belongs to another environment; also triggered when the client sends the evaluator ID instead of the version ID.

Common situations: Frontend holding a stale list after a delete; confusing evaluatorId with evaluatorVersionId in the request payload; switching dev/prod datasources; IDs reused from an old database snapshot.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/25f3f0ff318e2558. Report an issue: GitHub.