{"record":{"id":"62aa0d7797f003b9","repo":"apache/beam","slug":"instance-connection-uri-cannot-be-empty","errorCode":null,"errorMessage":"Instance connection URI cannot be empty","messagePattern":"Instance connection URI cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py","lineNumber":150,"sourceCode":"        db_id: Database identifier/name.\n        refresh_strategy: Strategy for refreshing connection (default: LAZY).\n        connector_kwargs: Additional keyword arguments for the\n          Cloud SQL Python Connector. Enables forward compatibility.\n        connect_kwargs: Additional keyword arguments for the client connect\n          method. Enables forward compatibility.\n    \"\"\"\n  db_adapter: DatabaseTypeAdapter\n  instance_connection_uri: str\n  user: str = field(default_factory=str)\n  password: str = field(default_factory=str)\n  db_id: str = field(default_factory=str)\n  refresh_strategy: RefreshStrategy = RefreshStrategy.LAZY\n  connector_kwargs: dict[str, Any] = field(default_factory=dict)\n  connect_kwargs: dict[str, Any] = field(default_factory=dict)\n\n  def __post_init__(self):\n    if not self.instance_connection_uri:\n      raise ValueError(\"Instance connection URI cannot be empty\")\n\n  def get_connector_handler(self) -> Callable[[], DBAPIConnection]:\n    \"\"\"Returns a function that creates a new database connection.\n\n      The returned connector function creates database connections that should\n      be properly closed by the caller when no longer needed.\n      \"\"\"\n    cloudsql_client = CloudSQLConnector(\n        refresh_strategy=self.refresh_strategy, **self.connector_kwargs)\n\n    cloudsql_connector = lambda: cloudsql_client.connect(\n        instance_connection_string=self.instance_connection_uri, driver=self.\n        db_adapter.value, user=self.user, password=self.password, db=self.db_id,\n        **self.connect_kwargs)\n\n    return cloudsql_connector\n\n  def get_db_url(self) -> str:","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py#L132-L168","documentation":"The Cloud SQL enrichment handler's connection config is a dataclass that validates in __post_init__ that instance_connection_uri is non-empty. This URI (format 'project:region:instance') is required for the Cloud SQL Python Connector to locate and open a database connection. Construction fails fast with ValueError when it is empty or missing.","triggerScenarios":"Calling CloudSQLConnectionConfig(...) without instance_connection_uri, or passing \"\" or None. Also occurs when the value is sourced from pipeline options or env vars that were not set.","commonSituations":"Building the config from YAML/JSON or env vars with a missing key; typos in the field name so the empty default is used; copying example code and deleting the URI line.","solutions":["Pass a non-empty instance_connection_uri in 'project:region:instance' format.","Verify the pipeline option / env var feeding the value is actually populated at runtime.","Add a pre-construction assertion that the URI is set before building the config."],"exampleFix":"# before\nconfig = CloudSQLConnectionConfig(instance_connection_uri=\"\", query_config=qcfg)\n# after\nconfig = CloudSQLConnectionConfig(instance_connection_uri=\"my-project:us-central1:my-instance\", query_config=qcfg)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["python","configuration","cloudsql","apache-beam"],"backgroundTag":"empty-required-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}