apache/beam · error · ValueError
A VPC network must be provided to use a private endpoint.
Error message
A VPC network must be provided to use a private endpoint.
What it means
VertexAIModelHandler raises ValueError in __init__ when private=True (a private Google Access endpoint) is requested but no VPC network is supplied. Private endpoints can only be reached through a specific VPC network, so the network parameter is mandatory in that mode.
Solutions
- Pass the full VPC network resource name, e.g. network='projects/PROJECT/global/networks/NETWORK', when setting private=True
- Set private=False if you actually intend to use the public endpoint
- Verify the network exists in the same project and that the caller has network permissions
Example fix
// before handler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l, private=True) // after handler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l, private=True, network='projects/p/global/networks/my-vpc')
Defensive patterns
Strategy: validation
Validate before calling
private = True
network = os.environ.get('VPC_NETWORK')
if private and not network:
raise ValueError('private=True requires network="projects/P/global/networks/N"')
handler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l, private=private, network=network) Try / catch
try:
handler = VertexAIModelHandlerGPU(..., private=True, network=network)
except ValueError as e:
logger.error('Vertex handler config invalid: %s', e)
raise Prevention
- Always set network together with private=True
- Store the VPC network resource name in pipeline config/env, not hardcoded flags
- Document that private endpoints require VPC access from the workers
When it happens
Trigger: Constructing VertexAIModelHandlerGPU with private=True while network=None (or network omitted).
Common situations: Deploying inference in a VPC-SC or private Google Access environment; copying public-endpoint config and only toggling private=True.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Endpoint has no models deployed to it.
- Expected image content in
- Failed to contact endpoint
- query cannot be empty
- query.project cannot be empty
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/85cdfd790348610e.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/ml/inference/vertex_ai_inference.py:144
self._env_vars = kwargs.get('env_vars', {})
self._invoke_route = invoke_route
if min_batch_size is not None:
self._batching_kwargs["min_batch_size"] = min_batch_size
if max_batch_size is not None:
self._batching_kwargs["max_batch_size"] = max_batch_size
if max_batch_duration_secs is not None:
self._batching_kwargs["max_batch_duration_secs"] = max_batch_duration_secs
if max_batch_weight is not None:
self._batching_kwargs["max_batch_weight"] = max_batch_weight
if element_size_fn is not None:
self._batching_kwargs['element_size_fn'] = element_size_fn
if batch_length_fn is not None:
self._batching_kwargs['length_fn'] = batch_length_fn
if batch_bucket_boundaries is not None:
self._batching_kwargs['bucket_boundaries'] = batch_bucket_boundaries
if private and network is None:
raise ValueError(
"A VPC network must be provided to use a private endpoint.")
# TODO: support the full list of options for aiplatform.init()
# See https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform#google_cloud_aiplatform_init
aiplatform.init(
project=project,
location=location,
experiment=experiment,
network=network)
# Check for liveness here but don't try to actually store the endpoint
# in the class yet
self.endpoint_name = endpoint_id
self.location = location
self.is_private = private
_ = self._retrieve_endpoint(
self.endpoint_name, self.location, self.is_private)View on GitHub (pinned to 12126d8942)