{"record":{"id":"84c4bf0166ee75ba","repo":"Tencent/WeKnora","slug":"failed-to-create-op-w","errorCode":null,"errorMessage":"failed to create op: %w","messagePattern":"failed to create op: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/repository/retriever/elasticsearch/v8/repository.go","lineNumber":203,"sourceCode":"func (e *elasticsearchRepository) BatchSave(ctx context.Context,\n\tembeddingList []*typesLocal.IndexInfo, additionalParams map[string]any,\n) error {\n\tlog := logger.GetLogger(ctx)\n\tif len(embeddingList) == 0 {\n\t\tlog.Warn(\"[Elasticsearch] Empty list provided to BatchSave, skipping\")\n\t\treturn nil\n\t}\n\n\tlog.Infof(\"[Elasticsearch] Batch saving %d indices\", len(embeddingList))\n\tindexRequest := e.client.Bulk().Index(e.index)\n\n\t// Add each document to the bulk request\n\tfor _, embedding := range embeddingList {\n\t\tembeddingDB := elasticsearchRetriever.ToDBVectorEmbedding(embedding, additionalParams)\n\t\terr := indexRequest.CreateOp(types.CreateOperation{Index_: &e.index}, embeddingDB)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"[Elasticsearch] Failed to create bulk operation: %v\", err)\n\t\t\treturn fmt.Errorf(\"failed to create op: %w\", err)\n\t\t}\n\t\tlog.Debugf(\"[Elasticsearch] Added chunk ID %s to bulk request\", embedding.ChunkID)\n\t}\n\n\t// Execute the bulk request\n\t_, err := indexRequest.Do(ctx)\n\tif err != nil {\n\t\tlog.Errorf(\"[Elasticsearch] Failed to execute bulk operation: %v\", err)\n\t\treturn fmt.Errorf(\"failed to do bulk: %w\", err)\n\t}\n\n\tlog.Infof(\"[Elasticsearch] Successfully batch saved %d indices\", len(embeddingList))\n\treturn nil\n}\n\n// DeleteByChunkIDList removes documents from the index based on chunk IDs\n// Returns an error if the delete operation fails\nfunc (e *elasticsearchRepository) DeleteByChunkIDList(ctx context.Context, chunkIDList []string, dimension int, knowledgeType string) error {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/repository/retriever/elasticsearch/v8/repository.go#L185-L221","documentation":"Elasticsearch v8 bulk-save guard: constructing the bulk index operation for an embedding document failed (serialization or client-side op creation error), aborting the batch before it is sent to the cluster.","triggerScenarios":"Thrown at internal/application/repository/retriever/elasticsearch/v8/repository.go:203 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for the failing document","Validate embedding payload shape before adding to the bulk request","Retry the batch after removing the problematic document"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}