{"record":{"id":"1d70c4e7d231f669","repo":"jd-opensource/joyagent-jdgenie","slug":"vector-is-empty","errorCode":null,"errorMessage":"vector is empty","messagePattern":"vector is empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/service/QdrantService.java","lineNumber":87,"sourceCode":"            } else {\n                client = new QdrantClient(QdrantGrpcClient.newBuilder(dataAgentConfig.getQdrantConfig().getHost(), dataAgentConfig.getQdrantConfig().getPort(), false).build());\n            }\n        }\n    }\n\n    @Override\n    public void destroy() {\n        if (client != null) {\n            client.close();\n        }\n    }\n\n    public List<Points.ScoredPoint> search(String collectionName, List<Float> vector, int limit, Points.Filter filter, List<String> payloads, Long timeout, TimeUnit timeUnit, Float scoreThreshold) throws ExecutionException, InterruptedException, TimeoutException {\n        if (StringUtils.isBlank(collectionName)) {\n            throw new IllegalArgumentException(\"collectionName is empty\");\n        }\n        if (CollectionUtils.isEmpty(vector)) {\n            throw new IllegalArgumentException(\"vector is empty\");\n        }\n        Points.SearchPoints.Builder requestBuilder = Points.SearchPoints.newBuilder();\n        requestBuilder.setCollectionName(collectionName);\n        requestBuilder.addAllVector(vector);\n        requestBuilder.setLimit(Math.min(limit, maxLimitSize));\n        if (Objects.nonNull(payloads)) {\n            requestBuilder.setWithPayload(include(payloads));\n        } else {\n            requestBuilder.setWithPayload(enable(true));\n        }\n        if (Objects.nonNull(filter)) {\n            requestBuilder.setFilter(filter);\n        }\n\n        if (Objects.nonNull(scoreThreshold)) {\n            requestBuilder.setScoreThreshold(scoreThreshold);\n        }\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/service/QdrantService.java#L69-L105","documentation":"QdrantService.search requires a non-empty query vector to build the SearchPoints request. When the vector list is null or empty it throws IllegalArgumentException(\"vector is empty\") instead of sending a malformed gRPC request.","triggerScenarios":"Calling search with an empty/null vector: the embedding model returned nothing, the embedding call failed silently upstream, or a List<Float> was initialized but never populated.","commonSituations":"Embedding API returning empty response; wrong dimension handling dropping all values; passing an unpopulated list due to an error swallowed earlier in the pipeline.","solutions":["Verify the embedding generation step upstream and check its logs for failures","Assert the vector is non-empty (and of expected dimension) before calling search","Fix embedding client configuration (API key, model name, dimension) if it silently returns empty"],"exampleFix":"// before\nList<Float> vector = embed(queryText);\nqdrantService.search(collection, vector, 10, null, null, 5L, TimeUnit.SECONDS, null);\n// after\nList<Float> vector = embed(queryText);\nif (vector == null || vector.isEmpty()) {\n    throw new IllegalStateException(\"embedding failed for query: \" + queryText);\n}\nqdrantService.search(collection, vector, 10, null, null, 5L, TimeUnit.SECONDS, null);","handlingStrategy":"validation","validationCode":"if (vector == null || vector.isEmpty() || vector.size() != EXPECTED_DIM) {\n    throw new IllegalArgumentException(\"query vector missing or wrong dimension\");\n}","typeGuard":"boolean isValidVector(List<Float> v) {\n    return v != null && !v.isEmpty() && v.stream().allMatch(Objects::nonNull);\n}","tryCatchPattern":"try {\n    return qdrantService.search(collectionName, vector, limit, filter, null, timeout, TimeUnit.SECONDS, threshold);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"vector is empty\")) {\n        log.error(\"embedding step produced empty vector\");\n    }\n    return Collections.emptyList();\n}","preventionTips":["Check the embedding result for null/empty immediately after the embedding call","Validate vector dimension matches the collection's configured dimension","Fail fast when the embedding API errors instead of propagating an empty list"],"tags":["java","qdrant","vector-database","validation"],"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"}