{"record":{"id":"841ffae82070a14c","repo":"remotion-dev/remotion","slug":"region-parameter-is-required-and-cannot-be-empty","errorCode":null,"errorMessage":"'region' parameter is required and cannot be empty or whitespace","messagePattern":"'region' parameter is required and cannot be empty or whitespace","errorType":"validation","errorClass":"RemotionInvalidArgumentException","httpStatus":null,"severity":"error","filePath":"packages/lambda-python/remotion_lambda/remotionclient.py","lineNumber":167,"sourceCode":"        ...     serve_url='https://api.example.com',\n        ...     function_name='my-function',\n        ...     session=session,\n        ...     config=config\n        ... )\n\n        Legacy usage (deprecated):\n\n        >>> client = RemotionClient(\n        ...     region='us-east-1',\n        ...     serve_url='https://api.example.com',\n        ...     function_name='my-function',\n        ...     access_key='AKIA...',\n        ...     secret_key='secret...'\n        ... )\n        \"\"\"\n       # Validate required parameters at construction time\n        if not region or not region.strip():\n            raise RemotionInvalidArgumentException(\"'region' parameter is required and cannot be empty or whitespace\")\n        if not serve_url or not serve_url.strip():\n            raise RemotionInvalidArgumentException(\"'serve_url' parameter is required and cannot be empty or whitespace\")\n        if not function_name or not function_name.strip():\n            raise RemotionInvalidArgumentException(\"'function_name' parameter is required and cannot be empty or whitespace\")\n\n\n        # Check for conflicting authentication methods\n        if session and (access_key or secret_key):\n            raise RemotionInvalidArgumentException(\n                \"Cannot specify both 'session' and explicit credentials \"\n                \"('access_key'/'secret_key'). Please use only 'session'.\"\n            )\n\n        # Handle deprecated credential parameters\n        if access_key is not None or secret_key is not None:\n            warnings.warn(\n                \"Parameters 'access_key' and 'secret_key' are deprecated \"\n                \"as of version 4.0.376 and will be removed in version 5.0.0. \"","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-python/remotion_lambda/remotionclient.py#L149-L185","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a valid AWS region string such as 'us-east-1' when constructing RemotionClient.","If reading from env, supply a default: region=os.environ.get('AWS_REGION') or 'us-east-1'.","Validate the resolved region value with a regex like ^[a-z]{2}-[a-z]+-[0-9]+$ before construction."],"exampleFix":"// before\nclient = RemotionClient(\n    region=os.environ.get('AWS_REGION'),  # may be None\n    serve_url=serve_url,\n    function_name=fn,\n)\n\n# after\nregion = os.environ.get('AWS_REGION') or 'us-east-1'\nclient = RemotionClient(\n    region=region,\n    serve_url=serve_url,\n    function_name=fn,\n)","handlingStrategy":"validation","validationCode":"import re\nAWS_REGION_RE = re.compile(r'^[a-z]{2}-[a-z]+-\\d+$')\ndef validate_region(region: str) -> str:\n    if not region or not region.strip():\n        raise ValueError('region required')\n    if not AWS_REGION_RE.match(region.strip()):\n        raise ValueError(f'invalid region format: {region!r}')\n    return region.strip()","typeGuard":"def is_valid_region(value) -> bool:\\n    return isinstance(value, str) and bool(re.match(r'^[a-z]{2}-[a-z]+-\\d+$', value.strip()))","tryCatchPattern":"try:\\n    client = RemotionClient(region=region, serve_url=serve_url, function_name=fn)\\nexcept RemotionInvalidArgumentException as e:\\n    raise SystemExit(f'Misconfigured client: {e}')","preventionTips":["Always pass an explicit region string; do not rely on os.environ.get('AWS_REGION') returning a value.","Use a config loader that fails fast when region is missing.","Assert the region matches the AWS_REGION regex before constructing the client."],"tags":["python","validation","constructor","region","aws"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}