{"record":{"id":"d7dfedec5a714e0c","repo":"apache/beam","slug":"failed-to-contact-endpoint-s-got-exception-s","errorCode":null,"errorMessage":"Failed to contact endpoint %s, got exception: %s","messagePattern":"Failed to contact endpoint (.+?), got exception: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/inference/vertex_ai_inference.py","lineNumber":196,"sourceCode":"        endpoint\n    Returns:\n      An aiplatform.Endpoint object\n    Raises:\n      ValueError: if endpoint is inactive or has no models deployed to it.\n    \"\"\"\n    if is_private:\n      endpoint: aiplatform.Endpoint = aiplatform.PrivateEndpoint(\n          endpoint_name=endpoint_id, location=location)\n      LOGGER.debug(\"Treating endpoint %s as private\", endpoint_id)\n    else:\n      endpoint = aiplatform.Endpoint(\n          endpoint_name=endpoint_id, location=location)\n      LOGGER.debug(\"Treating endpoint %s as public\", endpoint_id)\n\n    try:\n      mod_list = endpoint.list_models()\n    except Exception as e:\n      raise ValueError(\n          \"Failed to contact endpoint %s, got exception: %s\", endpoint_id, e)\n\n    if len(mod_list) == 0:\n      raise ValueError(\"Endpoint %s has no models deployed to it.\", endpoint_id)\n\n    return endpoint\n\n  def create_client(self) -> aiplatform.Endpoint:\n    \"\"\"Loads the Endpoint object used to build and send prediction request to\n    Vertex AI.\n    \"\"\"\n    # Check to make sure the endpoint is still active since pipeline\n    # construction time\n    ep = self._retrieve_endpoint(\n        self.endpoint_name, self.location, self.is_private)\n    return ep\n\n  def request(","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/inference/vertex_ai_inference.py#L178-L214","documentation":"_retrieve_endpoint verifies connectivity by calling endpoint.list_models(); any exception there is wrapped as ValueError('Failed to contact endpoint %s, got exception: %s', ...). Note the format-string args are passed as separate parameters (not %-formatted), so the displayed message can be misleading, but the intent is that the Vertex AI endpoint could not be contacted.","triggerScenarios":"Constructing VertexAIModelHandlerGPU or calling create_client when endpoint.list_models() fails: wrong endpoint id, wrong region, missing AI Platform permissions (aiplatform.endpoints.get), or no network path (e.g. private endpoint without VPC access).","commonSituations":"Typos in endpoint_id or location; service account lacking Vertex AI permissions; running on-prem/without VPC peering for a private endpoint; transient GCP API outages.","solutions":["Verify endpoint_id and location (project/region must match where the endpoint is deployed)","Grant the caller the aiplatform.endpoints.get/list permission (Vertex AI User role)","Check network reachability (VPC peering / Private Google Access for private endpoints) and retry on transient failures","Inspect the underlying exception (second arg of the raised ValueError) for the real cause"],"exampleFix":"// before\nhandler = VertexAIModelHandlerGPU(endpoint_id='123', location='us-east1', ...)\n// after  # endpoint actually lives in us-central1\nhandler = VertexAIModelHandlerGPU(endpoint_id='123', location='us-central1', ...)","handlingStrategy":"try-catch","validationCode":"# preflight check before building the pipeline\nfrom google.cloud import aiplatform\naiplatform.init(project=project, location=location)\nendpoint = aiplatform.Endpoint(endpoint_name=endpoint_id)\nmodels = endpoint.list_models()  # raises early if unreachable","typeGuard":null,"tryCatchPattern":"try:\n    handler = VertexAIModelHandlerGPU(endpoint_id=ep, project=p, location=l)\nexcept ValueError as e:\n    logger.error('Endpoint contact failed (check id/region/permissions/VPC): %s', e)\n    raise","preventionTips":["Verify endpoint_id and location against the GCP console before launching","Grant the job's service account Vertex AI User role","For private endpoints, confirm Private Google Access / VPC peering is configured","Catch and inspect the wrapped exception for transient-failure retries"],"tags":["apache-beam","vertex-ai","gcp","network","endpoint"],"backgroundTag":"api-request-failed","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"}