{"record":{"id":"7afdbfe6b7bc426c","repo":"jd-opensource/joyagent-jdgenie","slug":"error-7afdbf","errorCode":null,"errorMessage":"向量为空！","messagePattern":"向量为空！","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/service/QdrantService.java","lineNumber":239,"sourceCode":"        for (int i = 0; i < vectors.size(); i++) {\n            Points.PointStruct pointStruct = Points.PointStruct.newBuilder()\n                    .setId(id(UUID.fromString(idList.get(i))))\n                    .setVectors(vectors(vectors.get(i)))\n                    .putAllPayload(maps.get(i))\n                    .build();\n            pointStructList.add(pointStruct);\n        }\n\n        return client.upsertAsync(collectionName, pointStructList).get();\n    }\n\n    public Points.UpdateResult upsertVector(String collectionName, List<Float> vector, Map<String, JsonWithInt.Value> payload) throws ExecutionException, InterruptedException {\n        if (StringUtils.isBlank(collectionName)) {\n            throw new RuntimeException(\"集合名为空！\");\n        }\n\n        if (Objects.isNull(vector)) {\n            throw new RuntimeException(\"向量为空！\");\n        }\n\n        if (Objects.isNull(payload)) {\n            throw new RuntimeException(\"元数据为空！\");\n        }\n\n\n        List<Points.PointStruct> pointStructList = new ArrayList<>();\n\n        Points.PointStruct pointStruct = Points.PointStruct.newBuilder()\n                .setId(id(UUID.randomUUID()))\n                .setVectors(vectors(vector))\n                .putAllPayload(payload)\n                .build();\n        pointStructList.add(pointStruct);\n\n        return client.upsertAsync(collectionName, pointStructList).get();\n    }","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/service/QdrantService.java#L221-L257","documentation":"Parameter validation in QdrantService.upsertVector, the single-vector variant of upsertVectors: the vector argument is null, meaning there is no embedding to store for the point. The guard fails fast before constructing the PointStruct and calling Qdrant; fires when a caller attempts a single-point upsert without providing the vector data.","triggerScenarios":"Calling upsertVector with vector == null, typically because the embedding call returned null on failure, or an unset field in the source record was passed straight through.","commonSituations":"Embedding client returning null instead of throwing on API failure; text preprocessing producing no output so no embedding was computed; nullable embedding column in the database; wrong variable order in the call.","solutions":["Check why the embedding step returned null; make it throw or return Optional instead of null.","Guard the caller: skip the upsert when the vector is null and record the item for retry.","Verify the argument order (collectionName, vector, payload) at the call site.","Compute the embedding on demand if it was never generated, rather than upserting a null placeholder."],"exampleFix":"// before\nList<Float> vector = embeddingCache.get(text); // may be null\nservice.upsertVector(collection, vector, payload);\n// after\nList<Float> vector = Optional.ofNullable(embeddingCache.get(text))\n        .orElseGet(() -> embeddingClient.embed(text));\nif (vector != null) {\n    service.upsertVector(collection, vector, payload);\n}","handlingStrategy":"validation","validationCode":"if (vector == null || vector.isEmpty()) {\n    throw new IllegalArgumentException(\"vector must be computed before upsertVector\");\n}","typeGuard":"static boolean hasVector(List<Float> vector) {\n    return vector != null && !vector.isEmpty();\n}","tryCatchPattern":"try {\n    service.upsertVector(collection, vector, payload);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"向量为空\")) {\n        log.error(\"Null vector passed to upsertVector; embedding likely failed\", e);\n    }\n    throw e;\n}","preventionTips":["Make embedding clients throw or return Optional rather than null on failure","Guard nullable embedding fields from the database before upsert","Retry embedding generation instead of persisting a null placeholder"],"tags":["validation","qdrant","null-argument","java"],"backgroundTag":"null-argument","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"}