apache/beam · error · ValueError
URI must be provided for Milvus connection
Error message
URI must be provided for Milvus connection
What it means
MilvusConnectionParameters.__post_init__ requires a non-empty uri (e.g. 'https://localhost:19530' or 'milvus-demo.db.zillizcloud.com:19530'); without a URI there is no endpoint to attach the Milvus client to.
Solutions
- Pass a uri, e.g. MilvusConnectionParameters(uri='http://localhost:19530')
- For Zilliz Cloud / Milvus Lite use the appropriate https URI or local file path
- Verify the env var/config feeding uri is set and non-empty before constructing
- Ensure uri is a string, not None passed explicitly
Example fix
// before params = MilvusConnectionParameters(token=token) // after params = MilvusConnectionParameters(uri="http://localhost:19530", token=token)
Defensive patterns
Strategy: validation
Validate before calling
uri = os.environ.get("MILVUS_URI")
if not uri:
raise ValueError("MILVUS_URI must be set before creating Milvus connection params") Type guard
def has_uri(params) -> bool:
return isinstance(params.uri, str) and params.uri != "" Prevention
- Set MILVUS_URI in the environment or pipeline options before launch
- Default to 'http://localhost:19530' for local dev instead of leaving uri unset
- Validate config dicts for the uri key before constructing parameters
When it happens
Trigger: Constructing MilvusConnectionParameters() with uri=None or empty string '' — e.g. omitting the uri kwarg or passing Milvus uri via a variable that is unset/empty.
Common situations: Missing MILVUS_URI environment variable; building connection params from a config dict where the uri key is absent; local Milvus setups forgetting the 'http://localhost:19530' endpoint.
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
- Collection name must be provided
- One of location, url, host, or path must be provided for…
- Approximate Nearest Neighbor Search (ANNS) field must be…
- Batch size must be a positive integer
- Both a BigQuery table and a query were specified. Please…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8dcfab2f8c2b9766.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/rag/utils.py:68
and not using token authentication.
db_name: Database Name to connect to. Specifies which Milvus database to
use. Defaults to 'default'.
token: Authentication token as an alternative to username/password.
timeout: Connection timeout in seconds. Uses client default if None.
kwargs: Optional keyword arguments for additional connection parameters.
Enables forward compatibility.
"""
uri: str
user: str = field(default_factory=str)
password: str = field(default_factory=str)
db_name: str = "default"
token: str = field(default_factory=str)
timeout: Optional[float] = None
kwargs: dict[str, Any] = field(default_factory=dict)
def __post_init__(self):
if not self.uri:
raise ValueError("URI must be provided for Milvus connection")
# Generate unique alias if not provided. One-to-one mapping between alias
# and connection - each alias represents exactly one Milvus connection.
if "alias" not in self.kwargs:
alias = f"milvus_conn_{uuid.uuid4().hex[:8]}"
self.kwargs["alias"] = alias
class MilvusHelpers:
"""Utility class providing helper methods for Milvus vector db operations."""
@staticmethod
def sparse_embedding(
sparse_vector: Optional[tuple[list[int], list[float]]]
) -> Optional[dict[int, float]]:
if not sparse_vector:
return None
# Converts sparse embedding from (indices, values) tuple format to
# Milvus-compatible values dict format {dimension_index: value, ...}.View on GitHub (pinned to 12126d8942)