{"record":{"id":"1a13b0d2c99e80ff","repo":"Tencent/WeKnora","slug":"failed-to-check-collection-existence-w","errorCode":null,"errorMessage":"failed to check collection existence: %w","messagePattern":"failed to check collection existence: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/repository/retriever/milvus/repository.go","lineNumber":101,"sourceCode":"\treturn fmt.Sprintf(\"%s_%d\", m.collectionBaseName, dimension)\n}\n\n// ensureCollection ensures the collection exists for the given dimension\nfunc (m *milvusRepository) ensureCollection(ctx context.Context, dimension int) error {\n\tcollectionName := m.getCollectionName(dimension)\n\n\t// Check cache first\n\tif _, ok := m.initializedCollections.Load(dimension); ok {\n\t\treturn nil\n\t}\n\n\tlog := logger.GetLogger(ctx)\n\n\t// Check if collection exists\n\thasCollection, err := m.client.HasCollection(ctx, client.NewHasCollectionOption(collectionName))\n\tif err != nil {\n\t\tlog.Errorf(\"[Milvus] Failed to check collection existence: %v\", err)\n\t\treturn fmt.Errorf(\"failed to check collection existence: %w\", err)\n\t}\n\n\tif !hasCollection {\n\t\tlog.Infof(\"[Milvus] Creating collection %s with dimension %d\", collectionName, dimension)\n\n\t\t// Define schema\n\t\tschema := &entity.Schema{\n\t\t\tCollectionName: collectionName,\n\t\t\tDescription:    fmt.Sprintf(\"WeKnora embeddings collection with dimension %d\", dimension),\n\t\t\tAutoID:         false,\n\t\t\tFields: []*entity.Field{\n\t\t\t\tentity.NewField().\n\t\t\t\t\tWithName(fieldID).\n\t\t\t\t\tWithDataType(entity.FieldTypeVarChar).\n\t\t\t\t\tWithIsPrimaryKey(true).\n\t\t\t\t\tWithMaxLength(1024),\n\t\t\t\tentity.NewField().\n\t\t\t\t\tWithName(fieldEmbedding).","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/repository/retriever/milvus/repository.go#L83-L119","documentation":"Milvus collection bootstrap failed at the existence probe: HasCollection returned a transport/server error, so ensureCollection cannot decide whether to create or reuse the per-dimension collection and the save/copy operation aborts.","triggerScenarios":"Thrown at internal/application/repository/retriever/milvus/repository.go:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check Milvus connectivity and cluster health","Verify collection naming/credentials configuration","Retry the existence check on transient network errors"],"exampleFix":null,"handlingStrategy":"retry","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"}