{"record":{"id":"5a85c85ac0984b28","repo":"boto/boto3","slug":"unknown-keyword-argument-name","errorCode":null,"errorMessage":"Unknown keyword argument: {name}","messagePattern":"Unknown keyword argument: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"boto3/resources/base.py","lineNumber":116,"sourceCode":"        # Create a default client if none was passed\n        if kwargs.get('client') is not None:\n            self.meta.client = kwargs.get('client')\n        else:\n            self.meta.client = boto3.client(self.meta.service_name)\n\n        # Allow setting identifiers as positional arguments in the order\n        # in which they were defined in the ResourceJSON.\n        for i, value in enumerate(args):\n            setattr(self, f\"_{self.meta.identifiers[i]}\", value)\n\n        # Allow setting identifiers via keyword arguments. Here we need\n        # extra logic to ignore other keyword arguments like ``client``.\n        for name, value in kwargs.items():\n            if name == 'client':\n                continue\n\n            if name not in self.meta.identifiers:\n                raise ValueError(f'Unknown keyword argument: {name}')\n\n            setattr(self, f\"_{name}\", value)\n\n        # Validate that all identifiers have been set.\n        for identifier in self.meta.identifiers:\n            if getattr(self, identifier) is None:\n                raise ValueError(f'Required parameter {identifier} not set')\n\n    def __repr__(self):\n        identifiers = [\n            f'{identifier}={repr(getattr(self, identifier))}'\n            for identifier in self.meta.identifiers\n        ]\n        return f\"{self.__class__.__name__}({', '.join(identifiers)})\"\n\n    def __eq__(self, other):\n        # Should be instances of the same resource class\n        if other.__class__.__name__ != self.__class__.__name__:","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/boto/boto3/blob/6e10b029c1326a437932a8b24f38af69fd986e15/boto3/resources/base.py#L98-L134","documentation":"Resource classes generated by boto3's factory accept only their declared identifiers as keyword arguments (plus 'client'). If a kwarg name is not in self.meta.identifiers and is not 'client', __init__ raises ValueError('Unknown keyword argument: {name}'), to surface typos and API/model mismatches at construction time rather than as a silent attribute error later.","triggerScenarios":"Constructing a resource like ec2.Volume(volume_id='v-123') where 'volume_id' is not the declared identifier name; using the wrong identifier name from a different AWS API version; typoing an identifier.","commonSituations":"Upgrade of boto3/botocore changes identifier names; using a copy-pasted example from a different resource; constructing resources manually instead of via collection methods.","solutions":["Inspect the resource's identifiers via Resource.meta.identifiers to get the exact expected names.","Use the canonical identifier name (commonly 'id' for single-id resources).","Prefer loading resources through the service client or collection (e.g. ec2.Volume('v-123')) rather than guessing kwargs."],"exampleFix":"# before\nvol = ec2.Volume(volume_id='vol-123')\n# after\nvol = ec2.Volume('vol-123')\n# or\nvol = ec2.Volume(id='vol-123')  # if 'id' is the declared identifier","handlingStrategy":"validation","validationCode":"def build_resource(cls, **kwargs):\n    valid = set(cls.meta.identifiers) | {'client'}\n    bad = set(kwargs) - valid\n    assert not bad, f'Unknown kwargs for {cls.__name__}: {bad}; valid={valid}'\n    return cls(**kwargs)","typeGuard":"def is_known_identifier(cls, name) -> bool:\n    return name in set(cls.meta.identifiers) or name == 'client'","tryCatchPattern":"try:\n    res = svc.Resource(**kwargs)\nexcept ValueError as e:\n    if 'Unknown keyword argument' in str(e):\n        kwargs.pop(bad_name, None)\n        res = svc.Resource(**kwargs)\n    else:\n        raise","preventionTips":["Inspect cls.meta.identifiers before constructing resources.","Prefer positional args for single-id resources.","Use collection/parent methods to obtain resources."],"tags":["resources","factory","identifier","boto3"],"backgroundTag":null,"analyzedSha":"6e10b029c1326a437932a8b24f38af69fd986e15","analyzedAt":"2026-08-11T20:52:47.213Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}