remotion-dev/remotion · error · RemotionInvalidArgumentException

'region' parameter is required and cannot be empty or whites

Error message

'region' parameter is required and cannot be empty or whitespace

What it means

Constructor-time validation in the Python RemotionClient. Raised when the 'region' argument is None, empty, or whitespace-only. This is a fail-fast guard so downstream boto3 calls do not fail later with a more cryptic AWS error.

Source

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

        ...     serve_url='https://api.example.com',
        ...     function_name='my-function',
        ...     session=session,
        ...     config=config
        ... )

        Legacy usage (deprecated):

        >>> client = RemotionClient(
        ...     region='us-east-1',
        ...     serve_url='https://api.example.com',
        ...     function_name='my-function',
        ...     access_key='AKIA...',
        ...     secret_key='secret...'
        ... )
        """
       # Validate required parameters at construction time
        if not region or not region.strip():
            raise RemotionInvalidArgumentException("'region' parameter is required and cannot be empty or whitespace")
        if not serve_url or not serve_url.strip():
            raise RemotionInvalidArgumentException("'serve_url' parameter is required and cannot be empty or whitespace")
        if not function_name or not function_name.strip():
            raise RemotionInvalidArgumentException("'function_name' parameter is required and cannot be empty or whitespace")


        # Check for conflicting authentication methods
        if session and (access_key or secret_key):
            raise RemotionInvalidArgumentException(
                "Cannot specify both 'session' and explicit credentials "
                "('access_key'/'secret_key'). Please use only 'session'."
            )

        # Handle deprecated credential parameters
        if access_key is not None or secret_key is not None:
            warnings.warn(
                "Parameters 'access_key' and 'secret_key' are deprecated "
                "as of version 4.0.376 and will be removed in version 5.0.0. "

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pass a valid AWS region string such as 'us-east-1' when constructing RemotionClient.
  2. If reading from env, supply a default: region=os.environ.get('AWS_REGION') or 'us-east-1'.
  3. Validate the resolved region value with a regex like ^[a-z]{2}-[a-z]+-[0-9]+$ before construction.

Example fix

// before
client = RemotionClient(
    region=os.environ.get('AWS_REGION'),  # may be None
    serve_url=serve_url,
    function_name=fn,
)

# after
region = os.environ.get('AWS_REGION') or 'us-east-1'
client = RemotionClient(
    region=region,
    serve_url=serve_url,
    function_name=fn,
)
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

try:\n    client = RemotionClient(region=region, serve_url=serve_url, function_name=fn)\nexcept RemotionInvalidArgumentException as e:\n    raise SystemExit(f'Misconfigured client: {e}')

Prevention

When it happens

Trigger: Instantiating RemotionClient(region='', ...), RemotionClient(region=None, ...), or passing a region string composed only of spaces/tabs. Also triggered by reading region from an unset environment variable that yields None or empty.

Common situations: Forgetting to set AWS_REGION/AWS_DEFAULT_REGION before constructing the client; passing os.environ.get('AWS_REGION') (which returns None) directly; typos in the kwarg name; loading config from a YAML/JSON key that is missing.

Related errors


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