{"record":{"id":"2cebbeab1b47c863","repo":"remotion-dev/remotion","slug":"invalid-s3-client-parameters-for-get-bucket-locati","errorCode":null,"errorMessage":"Invalid S3 client parameters for get_bucket_location: {e}","messagePattern":"Invalid S3 client parameters for get_bucket_location: (.+?)","errorType":"exception","errorClass":"RemotionInvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/lambda-python/remotion_lambda/remotionclient.py","lineNumber":321,"sourceCode":"        \"\"\"\n        try:\n            # Type hint for the response from get_bucket_location\n            bucket_region_response: Dict[str, Any] = s3_client.get_bucket_location(Bucket=bucket_name)\n            location: Optional[str] = bucket_region_response.get('LocationConstraint')\n\n            # us-east-1 returns None for LocationConstraint\n            return location == self.region or (\n                location is None and self.region == REGION_US_EAST\n            )\n        except ClientError as e:\n            logger.debug(\n                \"Could not get bucket location for %s (possibly permission issue): %s\",\n                bucket_name,\n                e,\n            )\n            raise e\n        except ParamValidationError as e:\n            raise RemotionInvalidArgumentException(\n                f\"Invalid S3 client parameters for get_bucket_location: {e}\"\n            ) from e\n\n    def _get_or_create_bucket(self) -> str:\n        \"\"\"Get existing bucket or create a new one following JS SDK logic.\"\"\"\n        buckets = self._get_remotion_buckets()\n\n        if len(buckets) > 1:\n            raise RemotionException(\n                f\"You have multiple buckets ({', '.join(buckets)}) in your S3 region \"\n                f\"({self.region}) starting with \\\"remotionlambda-\\\". \"\n                \"Please see https://remotion.dev/docs/lambda/multiple-buckets.\"\n            )\n\n        if len(buckets) == 1:\n            return buckets[0]\n\n        bucket_name = self._make_bucket_name()","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-python/remotion_lambda/remotionclient.py#L303-L339","documentation":"Raised when boto3 rejects the parameters to get_bucket_location with a ParamValidationError (before any network call). The original ClientError is NOT caught here - it is re-raised; this wrapper only handles malformed parameter shapes passed to the S3 client.","triggerScenarios":"Calling _verify_bucket_region (used internally during _get_or_create_bucket) when bucket_name is None, empty, or not a string; when the S3 client itself was constructed with bad parameters; integration test stubs that feed non-string bucket names.","commonSituations":"Internal corruption of the bucket name (e.g. a bucket lookup returned an empty string); a malformed region propagating into the S3 client endpoint; mocking the S3 client incorrectly in tests; bucket name resolution returning a non-scalar value.","solutions":["Inspect the wrapped exception `e` (via __cause__) for the exact ParamValidationError field.","Confirm the resolved bucket name is a non-empty string before calling render APIs.","Validate that the configured region produces a valid S3 endpoint (e.g. 'us-east-1', not '').","If you control the session, ensure the boto3 Session was created with a valid region_name."],"exampleFix":"// before\nclient = RemotionClient(region='', serve_url=..., function_name=...)\nclient.renderMedia(...)\n\n# after\nclient = RemotionClient(region='us-east-1', serve_url=..., function_name=...)\nclient.renderMedia(...)","handlingStrategy":"try-catch","validationCode":"def preflight_s3(session, bucket_name: str, region: str) -> None:\n    if not isinstance(bucket_name, str) or not bucket_name.strip():\n        raise ValueError(f'invalid bucket_name: {bucket_name!r}')\n    if not re.match(r'^[a-z0-9][a-z0-9.-]*[a-z0-9]$', bucket_name) or len(bucket_name) > 63:\n        raise ValueError(f'bucket_name not S3-compliant: {bucket_name!r}')","typeGuard":"def is_valid_bucket_name(value) -> bool:\\n    return (isinstance(value, str)\\n            and 3 <= len(value) <= 63\\n            and bool(re.match(r'^[a-z0-9][a-z0-9.-]*[a-z0-9]$', value)))","tryCatchPattern":"try:\\n    client.render_media(...)\\nexcept RemotionInvalidArgumentException as e:\\n    cause = e.__cause__\\n    log.error('S3 param validation failed: %s', cause)\\n    raise","preventionTips":["Validate bucket names match S3 naming rules before relying on them.","Use a valid boto3 Session with a proper region_name.","In tests, stub boto3 with the exact parameter shapes boto3 expects."],"tags":["python","s3","validation","aws-sdk","bucket"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}