remotion-dev/remotion · error · RemotionInvalidArgumentException

Invalid S3 client parameters for create_bucket: {e}

Error message

Invalid S3 client parameters for create_bucket: {e}

What it means

Raised when boto3 rejects the parameters to create_bucket with a ParamValidationError before the API call. Distinguished from ClientError (permissions, bucket already owned, etc.) which is re-raised unchanged. Indicates a malformed parameter shape, typically the bucket name.

Source

Thrown at packages/lambda-python/remotion_lambda/remotionclient.py:354

        if len(buckets) == 1:
            return buckets[0]

        bucket_name = self._make_bucket_name()
        s3_client = self._create_s3_client()

        try:
            if self.region == REGION_US_EAST:
                s3_client.create_bucket(Bucket=bucket_name)
            else:
                s3_client.create_bucket(
                    Bucket=bucket_name,
                    CreateBucketConfiguration={'LocationConstraint': self.region},
                )
            return bucket_name
        except ClientError as e:
            raise e
        except ParamValidationError as e:
            raise RemotionInvalidArgumentException(
                f"Invalid S3 client parameters for create_bucket: {e}"
            ) from e

    def _upload_to_s3(self, bucket_name: str, key: str, payload: str) -> None: # Added type hints
        """Upload payload to S3."""
        s3_client = self._create_s3_client()
        try:
            s3_client.put_object(
                Bucket=bucket_name,
                Key=key,
                Body=payload,
                ContentType='application/json',
            )
        except ClientError as e:
            raise e
        except ParamValidationError as e:
            raise RemotionInvalidArgumentException(
                f"Invalid S3 client parameters for put_object: {e}"

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Inspect __cause__ (the ParamValidationError) to see which parameter failed validation.
  2. Verify the configured region is a valid AWS region identifier (e.g. 'us-east-1').
  3. Confirm _make_bucket_name returns a string between 3 and 63 chars matching ^[a-z0-9][a-z0-9.-]*[a-z0-9]$.
  4. Recreate the boto3 Session with valid credentials and region_name set.

Example fix

// before
client = RemotionClient(region='invalid-region', serve_url=..., function_name=...)
client.renderMedia(...)  # _make_bucket_name yields invalid name

# after
client = RemotionClient(region='us-east-1', serve_url=..., function_name=...)
client.renderMedia(...)
Defensive patterns

Strategy: try-catch

Validate before calling

AWS_REGION_RE = re.compile(r'^[a-z]{2}-[a-z]+-\d+$')
def valid_region_for_bucket(region: str) -> str:
    if not region or not AWS_REGION_RE.match(region):
        raise ValueError(f'invalid region for bucket creation: {region!r}')
    return region

Type guard

def is_aws_region(value) -> bool:\n    return isinstance(value, str) and bool(re.match(r'^[a-z]{2}-[a-z]+-\d+$', value))

Try / catch

try:\n    client.render_media(...)\nexcept RemotionInvalidArgumentException as e:\n    log.error('create_bucket param error: %s', e.__cause__)\n    raise

Prevention

When it happens

Trigger: Triggered by _get_or_create_bucket when no existing remotionlambda- bucket is found and the auto-generated name (_make_bucket_name) is invalid (None, empty, too long, contains invalid characters), or the S3 client itself was constructed with bad parameters.

Common situations: Region string malformed so the bucket-name generator produces an invalid name; CI environment overriding region; monkey-patched _make_bucket_name in tests returning None; corrupted session producing a bad S3 client.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/8fe80a8479c21001. Report an issue: GitHub.