alibaba/spring-ai-alibaba · warning

Failed to fetch evaluator name for id: {}

Error message

Failed to fetch evaluator name for id: {}

What it means

Inside ExperimentServiceImpl.getById, each evaluator config's name is enriched via evaluatorMapper.selectById. If that lookup throws (e.g., DB error, connection issue), the code logs this warning with the evaluator ID and the exception, then sets the config's evaluatorName to "Error Fetching Name" and continues. The request still succeeds but the returned evaluator config has a placeholder name.

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:157

        
        ExperimentDO experimentDO = experimentMapper.selectById(id);
        if (experimentDO == null) {
            log.warn("未找到ID为{}的实验", id);
            return null;
        }

        Experiment experiment = Experiment.fromDO(experimentDO);

        List<EvaluatorConfig> evaluatorConfigList = JSON.parseArray(experiment.getEvaluatorConfig(), EvaluatorConfig.class);

        evaluatorConfigList.stream()
                .filter(Objects::nonNull)
                .forEach(evaluatorConfig -> {
                    try {
                        EvaluatorDO evaluatorDO = evaluatorMapper.selectById(evaluatorConfig.getEvaluatorId());
                        evaluatorConfig.setEvaluatorName(evaluatorDO != null ? evaluatorDO.getName() : "Unknown Evaluator");
                    } catch (Exception e) {
                        log.warn("Failed to fetch evaluator name for id: {}", evaluatorConfig.getEvaluatorId(), e);
                        evaluatorConfig.setEvaluatorName("Error Fetching Name");
                    }
                });
        experiment.setEvaluatorConfig(JSON.toJSONString(evaluatorConfigList));
        return experiment;
    }

    @Override
    public List<ExperimentEvaluatorResult> getResults(Long experimentId) {
        log.info("查询实验结果: {}", experimentId);
        
        // 先检查实验是否存在
        ExperimentDO experiment = experimentMapper.selectById(experimentId);
        if (experiment == null) {
            log.warn("实验不存在: {}", experimentId);
            return null;
        }

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Inspect the full logged stack trace (the trailing exception 'e') for the underlying DB error and fix that root cause.
  2. Check database connectivity/pool health (e.g., Druid/HikariCP logs, max connections).
  3. Validate evaluator IDs stored in experiment.evaluatorConfig; clean up references to deleted evaluators.
  4. Optionally resolve names in batch before the loop so a single failure doesn't produce placeholder names.

Example fix

// before
evaluatorConfig.setEvaluatorName("Error Fetching Name"); // silently continues

// after
try {
    EvaluatorDO evaluatorDO = evaluatorMapper.selectById(cfg.getEvaluatorId());
    cfg.setEvaluatorName(evaluatorDO != null ? evaluatorDO.getName() : "Unknown Evaluator");
} catch (Exception e) {
    log.error("Failed to fetch evaluator name for id: {}", cfg.getEvaluatorId(), e);
    cfg.setEvaluatorName("Unknown Evaluator"); // and monitor via error-level log/metric
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check evaluator references before loading an experiment
List<Long> ids = configs.stream()
    .map(EvaluatorConfig::getEvaluatorId)
    .filter(Objects::nonNull)
    .toList();
ids.forEach(id -> { if (evaluatorMapper.selectById(id) == null) log.warn("Evaluator {} missing", id); });

Try / catch

try {
    Experiment exp = experimentService.getById(id);
    exp.getEvaluatorConfigList().stream()
        .filter(c -> "Error Fetching Name".equals(c.getEvaluatorName()))
        .forEach(c -> log.warn("Degraded evaluator name for id: {}", c.getEvaluatorId()));
} catch (Exception e) {
    // inspect logged cause: usually a DB connectivity/schema error
    throw new IllegalStateException("Failed to load experiment with evaluator enrichment", e);
}

Prevention

When it happens

Trigger: A database exception occurs during evaluatorMapper.selectById(evaluatorConfig.getEvaluatorId()) while loading an experiment whose evaluatorConfig JSON references evaluators — e.g., connection timeout, table lock, or schema mismatch.

Common situations: Transient DB connectivity loss under load; an evaluator was deleted so enrichment behaves differently; malformed evaluatorConfig JSON causing a bad evaluatorId; datasource failover mid-request.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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