{"record":{"id":"4af4e61cf4bfc1aa","repo":"jd-opensource/joyagent-jdgenie","slug":"query","errorCode":null,"errorMessage":"查询query为空！","messagePattern":"查询query为空！","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/service/VectorService.java","lineNumber":48,"sourceCode":"    private QdrantService qdrantService;\n\n    @Autowired\n    public void setEmbeddingService(EmbeddingService embeddingService) {\n        this.embeddingService = embeddingService;\n    }\n\n    @Autowired\n    public void setQdrantService(QdrantService qdrantService) {\n        this.qdrantService = qdrantService;\n    }\n\n\n    public List<Map<String, Object>> vectorRecall(VectorRecallReq req) {\n        if (StringUtils.isBlank(req.getCollectionName())) {\n            throw new RuntimeException(\"集合名称为空！\");\n        }\n        if (StringUtils.isBlank(req.getQuery())) {\n            throw new RuntimeException(\"查询query为空！\");\n        }\n\n        CompletableFuture<List<Map<String, Object>>> future = null;\n        try {\n            future = CompletableFuture.supplyAsync(() -> recall(req));\n            future.exceptionally(throwable -> null);\n            List<Map<String, Object>> maps = future.get(req.getTimeout(), TimeUnit.MILLISECONDS);\n            if (maps == null || maps.isEmpty()) {\n                log.error(\"vectorRecall empty: req:{}\", JSONObject.toJSONString(req));\n                return new ArrayList<>();\n            }\n            return maps;\n        } catch (Exception e) {\n            log.error(\"vectorRecall error: req:{}\", JSONObject.toJSONString(req), e);\n            if (future != null) {\n                try {\n                    future.cancel(true);\n                } catch (Exception e1) {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/service/VectorService.java#L30-L66","documentation":"VectorService.vectorRecall throws this when VectorRecallReq.getQuery() is blank. Without a query string there is nothing to embed and search against in the vector store, so the request is rejected before any embedding or Qdrant call.","triggerScenarios":"Calling vectorRecall with an empty/whitespace query — typically an empty user input passed straight through, or a pipeline step that should have filled the query field didn't run.","commonSituations":"User submitted an empty search box; an upstream NLU/rewriting step returned an empty string; trimming/normalization stripped the query to nothing before the call.","solutions":["Guard caller-side: only invoke vectorRecall when the query text is non-blank after trimming.","Fix the upstream step responsible for producing the query (user input handling, query rewrite).","Provide a default/fallback behavior for empty user input instead of calling the vector service.","Include the request id in the error for tracing empty-input occurrences."],"exampleFix":"// before\nString query = userInput.trim().toLowerCase();\nreq.setQuery(query);\nvectorService.vectorRecall(req);\n// after\nString query = userInput == null ? \"\" : userInput.trim();\nif (StringUtils.isBlank(query)) {\n    return Collections.emptyList(); // skip vector recall for empty input\n}\nreq.setQuery(query);\nvectorService.vectorRecall(req);","handlingStrategy":"validation","validationCode":"// java (caller)\nif (StringUtils.isBlank(req.getQuery())) {\n    return Collections.emptyList(); // skip recall entirely\n}","typeGuard":"boolean hasQuery(VectorRecallReq req) {\n    return req != null && StringUtils.isNotBlank(req.getQuery());\n}","tryCatchPattern":"try {\n    return vectorService.vectorRecall(req);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"查询query为空\")) {\n        log.warn(\"skipped vector recall: empty query\");\n        return Collections.emptyList();\n    }\n    throw e;\n}","preventionTips":["Trim and check user input before building the request.","Make upstream query-rewrite steps fail loudly instead of emitting empty strings.","Skip vector recall for blank input instead of relying on the service to reject it."],"tags":["validation","vector-search","java","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"2417e0b8b636d941ad5fb14c59b20dddfef5375d","analyzedAt":"2026-09-08T11:28:19.414Z","contentChangedAt":"2026-09-08T11:28:19.414Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}