{"record":{"id":"6c40e18c60f1458d","repo":"apache/beam","slug":"google-cloud-recommendation-ai-not-supported-for-this","errorCode":null,"errorMessage":"Google Cloud Recommendation AI not supported for this execution environment (could not import google.cloud.recommendationengine).","messagePattern":"Google Cloud Recommendation AI not supported for this execution environment \\(could not import google\\.cloud\\.recommendationengine\\)\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/ml/gcp/recommendations_ai.py","lineNumber":42,"sourceCode":"from typing import Sequence\n\nfrom cachetools.func import ttl_cache\nfrom google.api_core.retry import Retry\n\nfrom apache_beam import pvalue\nfrom apache_beam.metrics import Metrics\nfrom apache_beam.options.pipeline_options import GoogleCloudOptions\nfrom apache_beam.transforms import DoFn\nfrom apache_beam.transforms import ParDo\nfrom apache_beam.transforms import PTransform\nfrom apache_beam.transforms.util import GroupIntoBatches\nfrom apache_beam.utils import retry\n\n# pylint: disable=wrong-import-order, wrong-import-position, ungrouped-imports\ntry:\n  from google.cloud import recommendationengine\nexcept ImportError:\n  raise ImportError(\n      'Google Cloud Recommendation AI not supported for this execution '\n      'environment (could not import google.cloud.recommendationengine).')\n# pylint: enable=wrong-import-order, wrong-import-position, ungrouped-imports\n\n__all__ = [\n    'CreateCatalogItem',\n    'WriteUserEvent',\n    'ImportCatalogItems',\n    'ImportUserEvents',\n    'PredictUserEvent'\n]\n\nFAILED_CATALOG_ITEMS = \"failed_catalog_items\"\nMAX_RETRIES = 5\n\n\n@ttl_cache(maxsize=128, ttl=3600)\ndef get_recommendation_prediction_client():","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/gcp/recommendations_ai.py#L24-L60","documentation":"Module-level guard in recommendations_ai.py: the google.cloud.recommendationengine package could not be imported, so the Recommendations AI connector is unusable in this environment. The error surfaces at module import, not at transform runtime.","triggerScenarios":"Thrown at sdks/python/apache_beam/ml/gcp/recommendations_ai.py:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install the client library: pip install google-cloud-recommendation-ai","Install the Beam extra that bundles GCP connectors: pip install 'apache_beam[gcp]'"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}