{"id":"510fdf9b970ef63c","repo":"boto/boto3","slug":"self-class-name-has-no-load-method","errorCode":null,"errorMessage":"{self.__class__.__name__} has no load method","messagePattern":"(.+?) has no load method","errorType":"exception","errorClass":"ResourceLoadException","httpStatus":null,"severity":"error","filePath":"boto3/resources/factory.py","lineNumber":383,"sourceCode":"        snake_cased,\n        member_model,\n        service_context,\n    ):\n        \"\"\"\n        Creates a new property on the resource to lazy-load its value\n        via the resource's ``load`` method (if it exists).\n        \"\"\"\n\n        # The property loader will check to see if this resource has already\n        # been loaded and return the cached value if possible. If not, then\n        # it first checks to see if it CAN be loaded (raise if not), then\n        # calls the load before returning the value.\n        def property_loader(self):\n            if self.meta.data is None:\n                if hasattr(self, 'load'):\n                    self.load()\n                else:\n                    raise ResourceLoadException(\n                        f'{self.__class__.__name__} has no load method'\n                    )\n\n            return self.meta.data.get(name)\n\n        property_loader.__name__ = str(snake_cased)\n        property_loader.__doc__ = docstring.AttributeDocstring(\n            service_name=service_context.service_name,\n            resource_name=resource_name,\n            attr_name=snake_cased,\n            event_emitter=factory_self._emitter,\n            attr_model=member_model,\n            include_signature=False,\n        )\n\n        return property(property_loader)\n\n    def _create_waiter(","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/boto/boto3/blob/c7b4afac237b976d48395d7523eaf7cec3a450b3/boto3/resources/factory.py#L365-L401","documentation":"Raised by the auto-loaded property created in _create_autoload_property when meta.data is None (the resource has not been hydrated) and the resource class has no load method. The property loader checks hasattr(self, 'load'); if absent, it cannot fetch data to satisfy the attribute access, so ResourceLoadException is raised. Not every resource model defines a load action; those that do not cannot lazy-load attributes.","triggerScenarios":"Accessing a data attribute (e.g. obj.last_modified) on a resource that was constructed without data and whose model has no load action. E.g. some S3 Object sub-resources or relation-only resources.","commonSituations":"Constructing a resource from identifiers only and then reading a data field; accessing attributes on a resource type that the service model marks as having no load; calling .load() implicitly via property access after a failed/empty response.","solutions":["Hydrate the resource explicitly by performing a describing action (e.g. obj = bucket.Object('k'); obj.get()) so meta.data is populated.","Check hasattr(resource, 'load') before accessing data attributes.","Use the low-level client to fetch the data if the resource has no load action."],"exampleFix":"# before\nobj = s3.Object('mybucket', 'k')\nprint(obj.last_modified)  # no data, no load method -> error\n\n# after\nobj = s3.Object('mybucket', 'k')\nobj.load()  # or obj.get() then re-access\nprint(obj.last_modified)\n# guard:\nif hasattr(obj, 'load'):\n    obj.load()","handlingStrategy":"try-catch","validationCode":"def safe_get_attr(resource, attr_name):\n    if resource.meta.data is None:\n        if hasattr(resource, 'load'):\n            resource.load()\n        else:\n            return None\n    return getattr(resource, attr_name, None)","typeGuard":"def can_load(resource) -> bool:\n    return hasattr(resource, 'load') or resource.meta.data is not None","tryCatchPattern":"from boto3.exceptions import ResourceLoadException\ntry:\n    val = resource.some_attribute\nexcept ResourceLoadException:\n    # resource has no load method; fetch via client or skip\n    val = resource.meta.client.get_object(Bucket=..., Key=...)","preventionTips":["Always call .load() (or a describing action) before reading data attributes on identifier-only resources.","Guard attribute access with hasattr(resource, 'load').","Know which resource types lack a load action in the service model."],"tags":["resources","lazy-load","resource-load-exception","factory"],"analyzedSha":"c7b4afac237b976d48395d7523eaf7cec3a450b3","analyzedAt":"2026-08-04T20:35:51.598Z","schemaVersion":2}