{"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/c7b4afac237b976d48395d7523eaf7cec3a450b3/boto3/session.py#L423-L459","documentation":"Raised as boto3.exceptions.UnknownAPIVersionError by Session.resource() when an explicit api_version argument does not match any resource data file for the service (DataNotFoundError from load_service_model). resource() must pair a resource model with a client model of the same API version, so an unrecognized version is rejected and the valid versions are listed in the message.","triggerScenarios":"Calling boto3.resource('service', api_version='YYYY-MM-DD') with a date that is not a valid resource-model API version for that service — a typo, a wrong format, a version newer than the bundled data, or a version that exists only as a botocore service model (not as a boto3 resource model).","commonSituations":"Hard-coding an api_version from docs that predates the resource model; bumping botocore data without updating boto3 resource data; passing a client-style API version string into resource(); using a version from a different service.","solutions":["Omit api_version to let boto3 resolve the latest paired resource/client version: boto3.resource('service').","Read the valid versions listed in the error message and pass one of those exact strings.","Upgrade boto3 (and botocore) so the requested newer API version is available.","If you specifically need an API version with no resource model, use boto3.client('service', api_version=...) which supports all botocore service-model versions."],"exampleFix":"// before\nboto3.resource('s3', api_version='2001-01-01')  # not a valid resource api version\n\n// after\nboto3.resource('s3')  # use latest\n# or pick from the versions listed in the error:\nboto3.resource('s3', api_version='2006-03-01')","handlingStrategy":"validation","validationCode":"session = boto3.session.Session()\nvalid_versions = session._loader.list_api_versions(service_name, 'resources-1')\nif api_version not in valid_versions:\n    raise ValueError(f'{api_version} not in {valid_versions}')\nresource = session.resource(service_name, api_version=api_version)","typeGuard":"def is_valid_resource_api_version(service_name: str, api_version: str) -> bool:\n    session = boto3.session.Session()\n    versions = session._loader.list_api_versions(service_name, 'resources-1')\n    return api_version in versions","tryCatchPattern":"from boto3.exceptions import UnknownAPIVersionError\ntry:\n    res = boto3.resource(service_name, api_version=api_version)\nexcept UnknownAPIVersionError as e:\n    # e message lists valid versions; retry with the latest\n    res = boto3.resource(service_name)","preventionTips":["Omit api_version unless you have a specific reason to pin it.","When pinning, copy the exact version string from the error's valid-versions list or from boto3 data files.","Upgrade boto3/botocore before requiring a newer API version."],"tags":["boto3","session","resource-api","version-mismatch","config"],"analyzedSha":"c7b4afac237b976d48395d7523eaf7cec3a450b3","analyzedAt":"2026-08-04T20:35:51.598Z","schemaVersion":2}