{"record":{"id":"85cdfd790348610e","repo":"apache/beam","slug":"a-vpc-network-must-be-provided-to-use-a-private-endpoint","errorCode":null,"errorMessage":"A VPC network must be provided to use a private endpoint.","messagePattern":"A VPC network must be provided to use a private endpoint\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/vertex_ai_inference.py","lineNumber":144,"sourceCode":"    self._env_vars = kwargs.get('env_vars', {})\n    self._invoke_route = invoke_route\n    if min_batch_size is not None:\n      self._batching_kwargs[\"min_batch_size\"] = min_batch_size\n    if max_batch_size is not None:\n      self._batching_kwargs[\"max_batch_size\"] = max_batch_size\n    if max_batch_duration_secs is not None:\n      self._batching_kwargs[\"max_batch_duration_secs\"] = max_batch_duration_secs\n    if max_batch_weight is not None:\n      self._batching_kwargs[\"max_batch_weight\"] = max_batch_weight\n    if element_size_fn is not None:\n      self._batching_kwargs['element_size_fn'] = element_size_fn\n    if batch_length_fn is not None:\n      self._batching_kwargs['length_fn'] = batch_length_fn\n    if batch_bucket_boundaries is not None:\n      self._batching_kwargs['bucket_boundaries'] = batch_bucket_boundaries\n\n    if private and network is None:\n      raise ValueError(\n          \"A VPC network must be provided to use a private endpoint.\")\n\n    # TODO: support the full list of options for aiplatform.init()\n    # See https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform#google_cloud_aiplatform_init\n    aiplatform.init(\n        project=project,\n        location=location,\n        experiment=experiment,\n        network=network)\n\n    # Check for liveness here but don't try to actually store the endpoint\n    # in the class yet\n    self.endpoint_name = endpoint_id\n    self.location = location\n    self.is_private = private\n\n    _ = self._retrieve_endpoint(\n        self.endpoint_name, self.location, self.is_private)","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/vertex_ai_inference.py#L126-L162","documentation":"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.","triggerScenarios":"Constructing VertexAIModelHandlerGPU with private=True while network=None (or network omitted).","commonSituations":"Deploying inference in a VPC-SC or private Google Access environment; copying public-endpoint config and only toggling private=True.","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"],"exampleFix":"// before\nhandler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l, private=True)\n// after\nhandler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l, private=True, network='projects/p/global/networks/my-vpc')","handlingStrategy":"validation","validationCode":"private = True\nnetwork = os.environ.get('VPC_NETWORK')\nif private and not network:\n    raise ValueError('private=True requires network=\"projects/P/global/networks/N\"')\nhandler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l, private=private, network=network)","typeGuard":null,"tryCatchPattern":"try:\n    handler = VertexAIModelHandlerGPU(..., private=True, network=network)\nexcept ValueError as e:\n    logger.error('Vertex handler config invalid: %s', e)\n    raise","preventionTips":["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"],"tags":["apache-beam","vertex-ai","gcp","vpc","validation"],"backgroundTag":"missing-required-argument","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"}