Tencent/WeKnora · error

failed to check collection existence: %w

Error message

failed to check collection existence: %w

What it means

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.

Source

Thrown at internal/application/repository/retriever/milvus/repository.go:101

	return fmt.Sprintf("%s_%d", m.collectionBaseName, dimension)
}

// ensureCollection ensures the collection exists for the given dimension
func (m *milvusRepository) ensureCollection(ctx context.Context, dimension int) error {
	collectionName := m.getCollectionName(dimension)

	// Check cache first
	if _, ok := m.initializedCollections.Load(dimension); ok {
		return nil
	}

	log := logger.GetLogger(ctx)

	// Check if collection exists
	hasCollection, err := m.client.HasCollection(ctx, client.NewHasCollectionOption(collectionName))
	if err != nil {
		log.Errorf("[Milvus] Failed to check collection existence: %v", err)
		return fmt.Errorf("failed to check collection existence: %w", err)
	}

	if !hasCollection {
		log.Infof("[Milvus] Creating collection %s with dimension %d", collectionName, dimension)

		// Define schema
		schema := &entity.Schema{
			CollectionName: collectionName,
			Description:    fmt.Sprintf("WeKnora embeddings collection with dimension %d", dimension),
			AutoID:         false,
			Fields: []*entity.Field{
				entity.NewField().
					WithName(fieldID).
					WithDataType(entity.FieldTypeVarChar).
					WithIsPrimaryKey(true).
					WithMaxLength(1024),
				entity.NewField().
					WithName(fieldEmbedding).

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check Milvus connectivity and cluster health
  2. Verify collection naming/credentials configuration
  3. Retry the existence check on transient network errors
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/repository/retriever/milvus/repository.go:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/1a13b0d2c99e80ff. Report an issue: GitHub.