remotion-dev/remotion · error · RemotionInvalidArgumentException
Cannot specify both 'session' and explicit credentials ('acc
Error message
Cannot specify both 'session' and explicit credentials ('access_key'/'secret_key'). Please use only 'session'. What it means
Raised when the caller passes both a boto3 Session (the recommended auth method) and explicit access_key/secret_key credentials to the Python RemotionClient constructor. The library disallows mixing auth methods to avoid ambiguity about which credentials AWS will actually use.
Source
Thrown at packages/lambda-python/remotion_lambda/remotionclient.py:176
... 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. "
"Please migrate to using 'session' for improved security. ",
DeprecationWarning,
stacklevel=2,
)
# Validate both keys are provided together
if access_key and not secret_key:
raise RemotionInvalidArgumentException("'secret_key' must be provided when 'access_key' is specified")
if secret_key and not access_key:
raise RemotionInvalidArgumentException("'access_key' must be provided when 'secret_key' is specified")View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Pick ONE auth method: pass either session=... OR access_key/secret_key, never both.
- When migrating to a Session, delete the access_key and secret_key arguments entirely.
- If a Session already encapsulates credentials, do not also pass credentials as kwargs.
Example fix
// before
session = boto3.Session()
client = RemotionClient(
region=region,
serve_url=serve_url,
function_name=fn,
session=session,
access_key=os.environ['AWS_ACCESS_KEY_ID'], # conflict
)
# after
client = RemotionClient(
region=region,
serve_url=serve_url,
function_name=fn,
session=session,
) Defensive patterns
Strategy: validation
Validate before calling
def validate_auth_args(session, access_key, secret_key):
if session is not None and (access_key is not None or secret_key is not None):
raise ValueError('Pass either session= OR access_key/secret_key, not both')
return True Type guard
def uses_single_auth_method(session, access_key, secret_key) -> bool:\n return not (session is not None and (access_key is not None or secret_key is not None))
Try / catch
try:\n client = RemotionClient(region=region, serve_url=serve_url, function_name=fn, session=session)\nexcept RemotionInvalidArgumentException as e:\n raise SystemExit(f'Auth conflict: {e}') Prevention
- Standardize on boto3.Session for all credentials.
- When migrating, remove access_key/secret_key kwargs explicitly.
- Audit constructor calls in code review for mixed auth args.
When it happens
Trigger: Passing session=<boto3.Session(...)> together with access_key=..., or session=... plus secret_key=... The check fires whenever session is truthy AND at least one of access_key/secret_key is set.
Common situations: Migrating from explicit credentials to a Session but forgetting to remove the old access_key/secret_key kwargs; copy-pasting example code that combines both styles; loading a session from a shared utility while still passing credentials from env.
Related errors
- 'secret_key' must be provided when 'access_key' is specified
- 'access_key' must be provided when 'secret_key' is specified
- 'region' parameter is required and cannot be empty or whites
- 'serve_url' parameter is required and cannot be empty or whi
- 'function_name' parameter is required and cannot be empty or
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/fff281997b481819.
Report an issue: GitHub.