{"id":"5a85c85ac0984b28","repo":"boto/boto3","slug":"unknown-keyword-argument-name","errorCode":null,"errorMessage":"Unknown keyword argument: {name}","messagePattern":"Unknown keyword argument: (.+?)","errorType":"validation","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/c7b4afac237b976d48395d7523eaf7cec3a450b3/boto3/resources/base.py#L98-L134","documentation":"Raised by ServiceResource.__init__ when a keyword argument is passed that is not in the resource's declared identifier list (meta.identifiers) and is not 'client'. Resource constructors only accept their defined identifiers (e.g. a Bucket accepts 'name', an Object accepts 'bucket' and 'key'); any other kwarg is rejected to fail fast on typos and mismatches.","triggerScenarios":"s3.Bucket(bucket_name='mybucket') — should be s3.Bucket('mybucket') or s3.Bucket(name='mybucket'). Also s3.Object(bucket='b', key='k', extra='x') where 'extra' is not an identifier.","commonSituations":"Guessing constructor parameter names instead of checking the resource model; passing client-creation kwargs (like region_name) into a resource constructor; version differences where identifier names changed.","solutions":["Check resource.meta.identifiers for the accepted keyword names.","Pass identifiers positionally to avoid name mismatches.","Use the parent resource's accessors (e.g. bucket.Object(key='k')) which fill identifiers automatically."],"exampleFix":"# before\nbucket = s3.Bucket(bucket_name='mybucket')\n\n# after\nbucket = s3.Bucket('mybucket')\n# or\nbucket = s3.Bucket(name='mybucket')","handlingStrategy":"validation","validationCode":"def safe_resource(resource_cls, **kwargs):\n    allowed = set(resource_cls.meta.identifiers) | {'client'}\n    bad = set(kwargs) - allowed\n    if bad:\n        raise ValueError(f'Unknown kwargs for {resource_cls.__name__}: {bad}. Allowed: {allowed}')\n    return resource_cls(**kwargs)","typeGuard":"def accepted_identifiers(resource_cls) -> set:\n    return set(resource_cls.meta.identifiers)","tryCatchPattern":null,"preventionTips":["Inspect resource.meta.identifiers before constructing resources programmatically.","Prefer positional args or parent-resource accessors (bucket.Object(...)) over guessing kwarg names.","Keep a reference of identifier names per service when building resource factories."],"tags":["resources","constructor","identifier","validation"],"analyzedSha":"c7b4afac237b976d48395d7523eaf7cec3a450b3","analyzedAt":"2026-08-04T20:35:51.598Z","schemaVersion":2}