boto/boto3 · error · ValueError

Required parameter not set

Error message

Required parameter {identifier} not set

What it means

After processing positional and keyword arguments, Resource.__init__ verifies every declared identifier received a non-None value. If any identifier is still None, it raises ValueError('Required parameter {identifier} not set'). This catches incomplete construction before the resource is used in a service call that would fail server-side.

Solutions

  1. Provide all declared identifiers — check Resource.meta.identifiers for the required set and order.
  2. Use keyword arguments to avoid positional-order mistakes.
  3. Acquire the resource from a parent or collection (e.g. bucket.Object(key=...)) which fills in identifiers automatically.

Example fix

# before
obj = s3.Object('my-bucket')  # missing 'key'
# after
obj = s3.Object('my-bucket', 'path/to/file.txt')
# or
obj = s3.Object(bucket_name='my-bucket', key='path/to/file.txt')
Defensive patterns

Strategy: validation

Validate before calling

def build_resource(cls, *args, **kwargs):
    ids = list(cls.meta.identifiers)
    provided = list(args) + [kwargs.get(i) for i in ids[len(args):]]
    missing = [i for i, v in zip(ids, provided) if v is None]
    assert not missing, f'Missing required identifiers: {missing}'
    return cls(*args, **kwargs)

Type guard

def all_identifiers_set(cls, args, kwargs) -> bool:
    ids = list(cls.meta.identifiers)
    if len(args) >= len(ids):
        return True
    return all(kwargs.get(i) is not None for i in ids[len(args):])

Try / catch

try:
    res = svc.Resource(*args, **kwargs)
except ValueError as e:
    if 'not set' in str(e):
        # fetch identifiers from parent/collection
        res = parent.Resource(id_arg=known_id)
    else:
        raise

Prevention

When it happens

Trigger: Constructing a resource that needs multiple identifiers (e.g. S3 Object requires bucket_name and key) but only supplying some; passing positional args in the wrong order so a later identifier stays None.

Common situations: Forgetting the second identifier for resources keyed by (bucket, key), (instance_id, device), etc.; mis-ordering positional args.

Related errors


AI-assisted analysis of boto/boto3@6e10b029c1 (2026-08-11). Data as JSON: /api/errors/6563e5fcf9a924a0. Report an issue: GitHub.

Appendix: source

Thrown at boto3/resources/base.py:123

        # in which they were defined in the ResourceJSON.
        for i, value in enumerate(args):
            setattr(self, f"_{self.meta.identifiers[i]}", value)

        # Allow setting identifiers via keyword arguments. Here we need
        # extra logic to ignore other keyword arguments like ``client``.
        for name, value in kwargs.items():
            if name == 'client':
                continue

            if name not in self.meta.identifiers:
                raise ValueError(f'Unknown keyword argument: {name}')

            setattr(self, f"_{name}", value)

        # Validate that all identifiers have been set.
        for identifier in self.meta.identifiers:
            if getattr(self, identifier) is None:
                raise ValueError(f'Required parameter {identifier} not set')

    def __repr__(self):
        identifiers = [
            f'{identifier}={repr(getattr(self, identifier))}'
            for identifier in self.meta.identifiers
        ]
        return f"{self.__class__.__name__}({', '.join(identifiers)})"

    def __eq__(self, other):
        # Should be instances of the same resource class
        if other.__class__.__name__ != self.__class__.__name__:
            return False

        # Each of the identifiers should have the same value in both
        # instances, e.g. two buckets need the same name to be equal.
        for identifier in self.meta.identifiers:
            if getattr(self, identifier) != getattr(other, identifier):
                return False

View on GitHub (pinned to 6e10b029c1)