{"record":{"id":"395ebbfdb1cda81e","repo":"JuliusBrussee/caveman","slug":"install-caveman-middleware-google-to-use-the-google-adapter","errorCode":null,"errorMessage":"Install caveman-middleware[google] to use the Google adapter","messagePattern":"Install caveman-middleware\\[google\\] to use the Google adapter","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"packages/middleware/python/caveman_middleware/google.py","lineNumber":21,"sourceCode":"Install the transport through HttpOptions.httpx_client/httpx_async_client. Wrap\nthe existing client or chat to register the recovery executor in its native AFC\nloop. The SDK keeps provider auth, Vertex configuration, retries and history.\n\"\"\"\nimport codecs\nimport contextvars\nimport functools\nimport json\nimport re\nimport uuid\nfrom urllib.parse import urlsplit\n\ntry:\n    import httpx\n    from google import genai\n    from google.genai import types\n    from google.genai.chats import Chat, AsyncChat\nexcept ModuleNotFoundError as error:\n    raise ImportError(\"Install caveman-middleware[google] to use the Google adapter\") from error\n\nfrom caveman_cloud.middleware import Adapter, Candidate, MiddlewareRuntime, AsyncMiddlewareRuntime, sha256\nfrom ._native import Attempt, manifest, owner, plain\nfrom ._versions import supports_framework\nfrom ._usage import usage\nfrom ._google_wire import parse, patch\n\n_invocation = contextvars.ContextVar(\"caveman_google_invocation\", default=None)\n\n\ndef _get(value, name, default=None):\n    if plain(value):\n        pieces = name.split(\"_\")\n        alias = pieces[0] + \"\".join(piece.title() for piece in pieces[1:])\n        return value.get(name, value.get(alias, default))\n    return getattr(value, name, default)\n\n","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/middleware/python/caveman_middleware/google.py#L3-L39","documentation":"The Google adapter imports optional Google Gen AI dependencies (httpx, google.genai, google.genai.chats) at module import time. If the google-genai package is missing, this ImportError is raised as a cause-chained error telling you to install the optional extra, instead of surfacing a raw ModuleNotFoundError.","triggerScenarios":"Importing caveman_middleware.google (or code that imports it) in an environment where google-genai (or httpx) is not installed. Occurs at import time, before any adapter call.","commonSituations":"Installing caveman-middleware without the [google] extra; a slim deployment image lacking the extra; a google-genai upgrade removing submodules like google.genai.chats, which also surfaces as ModuleNotFoundError.","solutions":["Run pip install \"caveman-middleware[google]\".","Add caveman-middleware[google] to your dependency manifest and reinstall.","Verify with python -c \"from google import genai\"; if it fails, install/repair google-genai at a supported version."],"exampleFix":"// before\npip install caveman-middleware\n// after\npip install \"caveman-middleware[google]\"","handlingStrategy":"try-catch","validationCode":"try:\n    from google import genai\nexcept ModuleNotFoundError:\n    raise RuntimeError(\"Run: pip install 'caveman-middleware[google]'\")","typeGuard":"def google_extra_installed() -> bool:\n    import importlib.util\n    return importlib.util.find_spec(\"google.genai\") is not None","tryCatchPattern":"try:\n    from caveman_middleware import google as caveman_google\nexcept ImportError as e:\n    logging.error(\"Install the extra: pip install 'caveman-middleware[google]' (%s)\", e)\n    raise","preventionTips":["Install with the [google] extra whenever using the Google adapter.","Pin caveman-middleware[google] in your dependency manifest.","Keep google-genai within the supported range (>=2.22,<3).","Smoke-test adapter imports in CI for every image."],"tags":["google","genai","dependency","optional-extra"],"backgroundTag":"missing-optional-dependency","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}