Skip to content

Commit 4f5593a

Browse files
authored
fix: handle empty endpoints during cloud function reuse (#17501)
Fixes an issue where reusing recently created Cloud Functions during Remote Function creation would sometimes result in an empty endpoint (`endpoint=""`). When a Cloud Function has been recently provisioned, its endpoint URI (`response.service_config.uri`) may occasionally be returned as an empty string if URL propagation is still pending. The remote function decorator previously only checked for `None`, proceeding to create the BigQuery Remote Function with `OPTIONS(endpoint='')`, which leads to validation failures when queries invoke the function. This PR changes the check to `if not cf_endpoint:` to handle both `None` and empty strings. If the endpoint is empty, it will route to `create_cloud_function`, which catches the `AlreadyExists` exception and safely retries/waits for the endpoint URI propagation to complete. Fixes #<525124882> 🦕
1 parent 6f99e23 commit 4f5593a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/bigframes/bigframes/functions/_function_session.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,9 @@ def wrapper(func):
592592
if reuse is not None:
593593
cf_endpoint = self._function_client.get_cloud_function_endpoint(cf_name)
594594

595-
if cf_endpoint is None:
595+
# If the endpoint is empty, the function might exist but the URL propagation is pending.
596+
# Running create_cloud_function will handle AlreadyExists and retry endpoint fetching.
597+
if not cf_endpoint:
596598
cf_endpoint = self._function_client.create_cloud_function(
597599
cf_name, cloud_func_spec
598600
)

0 commit comments

Comments
 (0)