{"record":{"id":"c3202d82bd1fb55f","repo":"jd-opensource/joyagent-jdgenie","slug":"vectorsize-vectors-size","errorCode":null,"errorMessage":"向量集合大小与元数据集合大小不一致，vectorSize：{\" + vectors.size() + \"}，payloadSize：{\" + payloads.size() + \"}","messagePattern":"向量集合大小与元数据集合大小不一致，vectorSize：(.+?)，payloadSize：(.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/service/QdrantService.java","lineNumber":215,"sourceCode":"    public Points.UpdateResult upsertVectorsPayloadTrans(String collectionName, List<String> idList, List<List<Float>> vectors, List<Map<String, Object>> payloads) throws ExecutionException, InterruptedException {\n        if (StringUtils.isBlank(collectionName)) {\n            throw new RuntimeException(\"集合名为空！\");\n        }\n\n        if (CollectionUtils.isEmpty(idList)) {\n            throw new RuntimeException(\"向量id集合为空！\");\n        }\n\n        if (CollectionUtils.isEmpty(vectors)) {\n            throw new RuntimeException(\"向量集合为空！\");\n        }\n\n        if (CollectionUtils.isEmpty(payloads)) {\n            throw new RuntimeException(\"元数据集合为空！\");\n        }\n\n        if (vectors.size() != payloads.size()) {\n            throw new RuntimeException(\"向量集合大小与元数据集合大小不一致，vectorSize：\" + vectors.size() + \"，payloadSize：\" + payloads.size());\n        }\n\n        List<Map<String, JsonWithInt.Value>> maps = transPayloadMap(payloads);\n\n        List<Points.PointStruct> pointStructList = new ArrayList<>();\n        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 {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/service/QdrantService.java#L197-L233","documentation":"upsertVectorsPayloadTrans enforces vectors.size() == payloads.size() so each vector is stored with exactly one payload by index. This guard fires on a length mismatch; the message includes both sizes.","triggerScenarios":"Calling upsertVectorsPayloadTrans where the vector list and payload list have different element counts, e.g. 50 embeddings but 49 payloads because one document's metadata extraction was skipped.","commonSituations":"Per-item metadata generation failing for some items while embedding succeeded for all; chunking/merging bugs when splitting large documents; concurrent population of the lists; filtering applied to one list after both were built.","solutions":["Build vectors, payloads, and ids in a single iteration over the same source items so sizes cannot diverge.","Use the vectorSize/payloadSize values in the message to identify which side is short and inspect that pipeline stage.","Add a caller-side assertion with per-item diagnostics before calling the service.","If items can legitimately lack metadata, pad with empty maps instead of omitting entries."],"exampleFix":"// before\nitems.forEach(i -> vectors.add(embed(i)));\nitems.stream().filter(i -> i.hasMeta()).forEach(i -> payloads.add(toPayload(i))); // diverges\nservice.upsertVectorsPayloadTrans(collection, ids, vectors, payloads);\n// after\nfor (Item i : items) {\n    vectors.add(embed(i));\n    payloads.add(toPayload(i)); // always add, empty map if no meta\n}\nservice.upsertVectorsPayloadTrans(collection, ids, vectors, payloads);","handlingStrategy":"validation","validationCode":"if (vectors == null || payloads == null || vectors.size() != payloads.size()) {\n    throw new IllegalArgumentException(\"size mismatch before upsertVectorsPayloadTrans: vectors=\"\n        + (vectors == null ? \"null\" : vectors.size()) + \" payloads=\" + (payloads == null ? \"null\" : payloads.size()));\n}","typeGuard":"static boolean areParallel(List<?> a, List<?> b) {\n    return a != null && b != null && a.size() == b.size();\n}","tryCatchPattern":"try {\n    service.upsertVectorsPayloadTrans(collection, ids, vectors, payloads);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"大小不一致\")) {\n        log.error(\"Trans upsert parallel-list mismatch: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Iterate source items once, appending to ids, vectors, and payloads together","Apply any filtering before building the lists, not to individual lists afterward","Add a batch-integrity unit test covering partial-metadata items"],"tags":["validation","qdrant","size-mismatch","java"],"backgroundTag":"shape-mismatch","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"}