apache/beam · error · ValueError

Collection name must be provided

Error message

Collection name must be provided

What it means

MilvusVectorSearchParameters wraps everything needed to execute a search against a specific Milvus collection. Since a search cannot proceed without a target collection, __post_init__ raises ValueError when collection_name is empty (its default).

Source

Thrown at sdks/python/apache_beam/ml/rag/enrichment/milvus_search.py:243

    partition_names: List of partition names to restrict the search to. If
      empty, all partitions will be searched.
    output_fields: List of field names to include in search results. If empty,
      only primary fields including distances will be returned.
    timeout: Search operation timeout in seconds. If not specified, the client's
      default timeout is used.
    round_decimal: Number of decimal places for distance/similarity scores.
      Defaults to -1 means no rounding.
  """
  collection_name: str
  search_strategy: SearchStrategyType
  partition_names: list[str] = field(default_factory=list)
  output_fields: list[str] = field(default_factory=list)
  timeout: Optional[float] = None
  round_decimal: int = -1

  def __post_init__(self):
    if not self.collection_name:
      raise ValueError("Collection name must be provided")

    if not self.search_strategy:
      raise ValueError("Search strategy must be provided")


@dataclass
class MilvusCollectionLoadParameters:
  """Parameters that control how Milvus loads a collection into memory.

  This class provides fine-grained control over collection loading, which is
  particularly important in resource-constrained environments. Proper
  configuration can significantly reduce memory usage and improve query
  performance by loading only necessary data.

  Args:
    refresh: If True, forces a reload of the collection even if already loaded.
      Ensures the most up-to-date data is in memory.
    resource_groups: List of resource groups to load the collection into. Can be

View on GitHub (pinned to 12126d8942)

Solutions

  1. Pass collection_name='<your collection>' when constructing MilvusVectorSearchParameters.
  2. Verify the config/env value feeding collection_name is non-empty before building the object.
  3. List existing collections (utility.list_collections()) to confirm the name exists in your Milvus instance.

Example fix

// before
params = MilvusVectorSearchParameters(search_strategy=strategy)
// after
params = MilvusVectorSearchParameters(collection_name='my_docs', search_strategy=strategy)
Defensive patterns

Strategy: validation

Validate before calling

collection = os.environ.get('MILVUS_COLLECTION')
if not collection:
    raise ValueError('MILVUS_COLLECTION env var must be set')

Try / catch

try:
    params = MilvusVectorSearchParameters(**cfg)
except ValueError as e:
    if 'Collection name' in str(e):
        logging.error('collection_name missing from Milvus config: %s', e)
    raise

Prevention

When it happens

Trigger: Constructing MilvusVectorSearchParameters(search_strategy=...) without collection_name, or collection_name='' — e.g. leaving it to be filled 'later' or a config key typo (collection vs collection_name).

Common situations: Environment-driven configs where the collection name env var is unset; copying parameter blocks between projects and forgetting to change the collection; typos in config keys.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/f8be113e5a08e500. Report an issue: GitHub.