{"record":{"id":"0f4defdda727d7ff","repo":"boto/boto3","slug":"the-service-name-resource-does-not-support-an","errorCode":null,"errorMessage":"The '{service_name}' resource does not support an API version of: {bad_api_version}\nValid API versions are: {available_api_versions}","messagePattern":"The '(.+?)' resource does not support an API version of: (.+?)\nValid API versions are: (.+?)","errorType":"exception","errorClass":"UnknownAPIVersionError","httpStatus":null,"severity":"error","filePath":"boto3/session.py","lineNumber":441,"sourceCode":"        \"\"\"\n        try:\n            resource_model = self._loader.load_service_model(\n                service_name, 'resources-1', api_version\n            )\n        except UnknownServiceError:\n            available = self.get_available_resources()\n            has_low_level_client = (\n                service_name in self.get_available_services()\n            )\n            raise ResourceNotExistsError(\n                service_name, available, has_low_level_client\n            )\n        except DataNotFoundError:\n            # This is because we've provided an invalid API version.\n            available_api_versions = self._loader.list_api_versions(\n                service_name, 'resources-1'\n            )\n            raise UnknownAPIVersionError(\n                service_name, api_version, ', '.join(available_api_versions)\n            )\n\n        if api_version is None:\n            # Even though botocore's load_service_model() can handle\n            # using the latest api_version if not provided, we need\n            # to track this api_version in boto3 in order to ensure\n            # we're pairing a resource model with a client model\n            # of the same API version.  It's possible for the latest\n            # API version of a resource model in boto3 to not be\n            # the same API version as a service model in botocore.\n            # So we need to look up the api_version if one is not\n            # provided to ensure we load the same API version of the\n            # client.\n            #\n            # Note: This is relying on the fact that\n            #   loader.load_service_model(..., api_version=None)\n            # and loader.determine_latest_version(..., 'resources-1')","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/boto/boto3/blob/6e10b029c1326a437932a8b24f38af69fd986e15/boto3/session.py#L423-L459","documentation":"`UnknownAPIVersionError` is raised when `Session.resource(service_name, api_version=...)` references an API version that has no `resources-1` data file for that service. boto3 lists the valid versions in the message. This happens because a resource model exists for the service, but not for the specific (often outdated or forward-dated) version you requested. Note that resource API versions and client API versions can legitimately differ, so pinning requires care.","triggerScenarios":"Calling `boto3.resource('s3', api_version='2004-01-01')` (a version with no resource data) or `api_version='2099-01-01'` (does not exist); pinning to a version copied from a different service's docs; using a version string that is a client-only API version.","commonSituations":"Hard-coding an old api_version for reproducibility that predates the resource model; mistyping the date format; environment with a partial boto3 install missing some version files.","solutions":["Omit `api_version` to let boto3 select the latest supported resource version.","Pick a version from the message's `available_api_versions` list (e.g. via `boto3.session.Session()._loader.list_api_versions(name, 'resources-1')`).","Upgrade boto3 — newer versions add more API version files.","Reinstall boto3 if a version that should exist is missing (corrupt install)."],"exampleFix":"# before\nboto3.resource('s3', api_version='2004-01-01')  # UnknownAPIVersionError\n\n# after\nboto3.resource('s3')  # latest resource API version\n# or pick from the listed valid versions, e.g.\nboto3.resource('s3', api_version='2006-03-01')","handlingStrategy":"validation","validationCode":"def safe_resource(session, service, api_version=None):\n    versions = session._loader.list_api_versions(service, 'resources-1')\n    if api_version and api_version not in versions:\n        api_version = None  # let boto3 pick the latest\n    return session.resource(service, api_version=api_version)","typeGuard":"def api_version_supported(session, service, version) -> bool:\n    return version in session._loader.list_api_versions(service, 'resources-1')","tryCatchPattern":"from boto3.exceptions import UnknownAPIVersionError\ntry:\n    res = session.resource(service, api_version=v)\nexcept UnknownAPIVersionError:\n    res = session.resource(service)  # default latest","preventionTips":["Avoid pinning api_version for resources unless reproducibility requires it.","Source valid versions from list_api_versions(service, 'resources-1').","Upgrade boto3 to gain newer resource API version files."],"tags":["session","resource","api-version","argument-validation"],"backgroundTag":null,"analyzedSha":"6e10b029c1326a437932a8b24f38af69fd986e15","analyzedAt":"2026-08-11T20:52:47.213Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}