{"id":"6563e5fcf9a924a0","repo":"boto/boto3","slug":"required-parameter-identifier-not-set","errorCode":null,"errorMessage":"Required parameter {identifier} not set","messagePattern":"Required parameter (.+?) not set","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"boto3/resources/base.py","lineNumber":123,"sourceCode":"        # 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__:\n            return False\n\n        # Each of the identifiers should have the same value in both\n        # instances, e.g. two buckets need the same name to be equal.\n        for identifier in self.meta.identifiers:\n            if getattr(self, identifier) != getattr(other, identifier):\n                return False","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/boto/boto3/blob/c7b4afac237b976d48395d7523eaf7cec3a450b3/boto3/resources/base.py#L105-L141","documentation":"Raised by ServiceResource.__init__ during the final validation loop: after processing all positional and keyword arguments, it checks every identifier in meta.identifiers; if any is still None, the resource cannot address a specific AWS entity and construction is aborted. This catches incomplete resource instantiation.","triggerScenarios":"s3.Object(key='k') — missing 'bucket' identifier. Also constructing a resource with fewer positional args than required identifiers, or passing an identifier as None explicitly.","commonSituations":"Building a child resource without supplying the parent identifier; optional fields mistaken for identifiers; programmatic resource creation where a loop omits one field.","solutions":["Supply every required identifier: s3.Object(bucket_name='b', key='k').","Use parent-resource accessors (bucket.Object(key='k')) which inject the parent identifier automatically.","Check resource.meta.identifiers and ensure none is None before or after construction."],"exampleFix":"# before\nobj = s3.Object(key='k')  # missing bucket\n\n# after\nobj = s3.Object(bucket_name='mybucket', key='k')\n# or via parent\nobj = s3.Bucket('mybucket').Object('k')","handlingStrategy":"validation","validationCode":"def build_resource(resource_cls, **kwargs):\n    missing = [i for i in resource_cls.meta.identifiers if kwargs.get(i) is None]\n    if missing:\n        raise ValueError(f'Missing required identifiers: {missing}')\n    return resource_cls(**kwargs)","typeGuard":"def all_identifiers_set(resource) -> bool:\n    return all(getattr(resource, i) is not None for i in resource.meta.identifiers)","tryCatchPattern":null,"preventionTips":["Prefer parent-resource accessors (Bucket().Object()) to avoid omitting inherited identifiers.","Programmatically assert every meta.identifiers value is non-None before constructing.","Log the identifier list for each resource type at startup."],"tags":["resources","constructor","identifier","required"],"analyzedSha":"c7b4afac237b976d48395d7523eaf7cec3a450b3","analyzedAt":"2026-08-04T20:35:51.598Z","schemaVersion":2}