{"id":"226664c0e24c98d2","repo":"boto/boto3","slug":"either-a-boto3-client-or-s3transfer-manager-transf","errorCode":null,"errorMessage":"Either a boto3.Client or s3transfer.manager.TransferManager must be provided","messagePattern":"Either a boto3\\.Client or s3transfer\\.manager\\.TransferManager must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"boto3/s3/transfer.py","lineNumber":412,"sourceCode":"        resolved = {}\n        for init_arg, val in init_args.items():\n            if val is not None:\n                resolved[init_arg] = val\n            elif TRANSFER_CONFIG_SUPPORTS_CRT:\n                resolved[init_arg] = self.UNSET_DEFAULT\n            else:\n                resolved[init_arg] = self.DEFAULTS[init_arg]\n        return resolved\n\n\nclass S3Transfer:\n    ALLOWED_DOWNLOAD_ARGS = TransferManager.ALLOWED_DOWNLOAD_ARGS\n    ALLOWED_UPLOAD_ARGS = TransferManager.ALLOWED_UPLOAD_ARGS\n    ALLOWED_COPY_ARGS = TransferManager.ALLOWED_COPY_ARGS\n\n    def __init__(self, client=None, config=None, osutil=None, manager=None):\n        if not client and not manager:\n            raise ValueError(\n                'Either a boto3.Client or s3transfer.manager.TransferManager '\n                'must be provided'\n            )\n        if manager and any([client, config, osutil]):\n            raise ValueError(\n                'Manager cannot be provided with client, config, '\n                'nor osutil. These parameters are mutually exclusive.'\n            )\n        if config is None:\n            config = TransferConfig()\n        if osutil is None:\n            osutil = OSUtils()\n        if manager:\n            self._manager = manager\n        else:\n            self._manager = create_transfer_manager(client, config, osutil)\n\n    def upload_file(","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/boto/boto3/blob/c7b4afac237b976d48395d7523eaf7cec3a450b3/boto3/s3/transfer.py#L394-L430","documentation":"Raised by S3Transfer.__init__ when neither a client nor a manager argument is supplied. The S3Transfer facade delegates all transfers to an underlying s3transfer TransferManager, which it either receives directly (manager=) or builds from a boto3 client (client=). With neither provided it has nothing to drive transfers with, so it raises this ValueError immediately.","triggerScenarios":"Instantiating S3Transfer() with no arguments: boto3.s3.transfer.S3Transfer(). Also reachable by explicitly passing client=None, manager=None.","commonSituations":"Directly constructing the lower-level S3Transfer class instead of using the injected s3.upload_file/download_file helpers; refactor that dropped the client argument; passing the client into the wrong parameter name.","solutions":["Pass an S3 client: transfer = boto3.s3.transfer.S3Transfer(boto3.client('s3')).","Prefer the injected high-level API (s3.upload_file / s3.download_file) which constructs the transfer machinery for you and rarely requires S3Transfer directly.","If supplying a custom TransferManager, pass it as manager= (and leave client/config/osutil unset)."],"exampleFix":"// before\ntransfer = boto3.s3.transfer.S3Transfer()  # no client/manager\n\n// after\nclient = boto3.client('s3')\ntransfer = boto3.s3.transfer.S3Transfer(client)","handlingStrategy":"validation","validationCode":"if client is None and manager is None:\n    raise ValueError('Pass either a client or a manager to S3Transfer')\ntransfer = boto3.s3.transfer.S3Transfer(client=client, manager=manager)","typeGuard":"def has_transfer_basis(client, manager) -> bool:\n    return client is not None or manager is not None","tryCatchPattern":"try:\n    transfer = boto3.s3.transfer.S3Transfer(client)\nexcept ValueError as e:\n    if 'must be provided' in str(e):\n        transfer = boto3.s3.transfer.S3Transfer(boto3.client('s3'))","preventionTips":["Prefer the injected s3.upload_file / s3.download_file helpers over constructing S3Transfer directly.","Always pass an existing S3 client when constructing S3Transfer.","Construct the client once and reuse it across transfers."],"tags":["boto3","s3","transfer","validation","api-misuse"],"analyzedSha":"c7b4afac237b976d48395d7523eaf7cec3a450b3","analyzedAt":"2026-08-04T20:35:51.598Z","schemaVersion":2}