jd-opensource/joyagent-jdgenie · error · RuntimeException

集合名称为空!

Error message

集合名称为空!

What it means

VectorService.vectorRecall throws this when VectorRecallReq.getCollectionName() is null, empty, or whitespace. The Qdrant vector search requires an explicit collection name to know which vector space to query.

Solutions

  1. Set collectionName on the VectorRecallReq before calling vectorRecall.
  2. Add upstream validation at the controller/caller layer to reject requests missing collectionName early.
  3. Check the config/property that supplies the default collection name is present and non-blank.
  4. Improve the exception message to include the trace/request context for easier debugging.

Example fix

// before
VectorRecallReq req = new VectorRecallReq();
req.setQuery("how to reset password");
vectorService.vectorRecall(req);
// after
VectorRecallReq req = new VectorRecallReq();
req.setQuery("how to reset password");
req.setCollectionName("faq_vectors");
Assert.hasText(req.getCollectionName(), "collectionName must be set");
vectorService.vectorRecall(req);
Defensive patterns

Strategy: validation

Validate before calling

// java (caller)
if (req == null || StringUtils.isBlank(req.getCollectionName())) {
    throw new IllegalArgumentException("collectionName must be provided");
}

Type guard

boolean hasCollection(VectorRecallReq req) {
    return req != null && StringUtils.isNotBlank(req.getCollectionName());
}

Try / catch

try {
    return vectorService.vectorRecall(req);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("集合名称为空")) {
        throw new IllegalArgumentException("vectorRecall requires collectionName", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling vectorRecall with a VectorRecallReq whose collectionName field was never set (new VectorRecallReq() with only query populated), or set from an upstream config/value that is blank.

Common situations: Caller builds the request conditionally and skips setting collectionName; config key for default collection missing so the value resolves to null; refactoring renamed the field but a call site still sets the old property.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08). Data as JSON: /api/errors/2281e2cc6f249edd. Report an issue: GitHub.

Appendix: source

Thrown at genie-backend/src/main/java/com/jd/genie/service/VectorService.java:45

public class VectorService {

    private EmbeddingService embeddingService;
    private QdrantService qdrantService;

    @Autowired
    public void setEmbeddingService(EmbeddingService embeddingService) {
        this.embeddingService = embeddingService;
    }

    @Autowired
    public void setQdrantService(QdrantService qdrantService) {
        this.qdrantService = qdrantService;
    }


    public List<Map<String, Object>> vectorRecall(VectorRecallReq req) {
        if (StringUtils.isBlank(req.getCollectionName())) {
            throw new RuntimeException("集合名称为空!");
        }
        if (StringUtils.isBlank(req.getQuery())) {
            throw new RuntimeException("查询query为空!");
        }

        CompletableFuture<List<Map<String, Object>>> future = null;
        try {
            future = CompletableFuture.supplyAsync(() -> recall(req));
            future.exceptionally(throwable -> null);
            List<Map<String, Object>> maps = future.get(req.getTimeout(), TimeUnit.MILLISECONDS);
            if (maps == null || maps.isEmpty()) {
                log.error("vectorRecall empty: req:{}", JSONObject.toJSONString(req));
                return new ArrayList<>();
            }
            return maps;
        } catch (Exception e) {
            log.error("vectorRecall error: req:{}", JSONObject.toJSONString(req), e);
            if (future != null) {

View on GitHub (pinned to 2417e0b8b6)