langchain-ai/langgraph · error · TypeError

{handler_type} must accept exactly 2 parameters (ctx, data),

Error message

{handler_type} must accept exactly 2 parameters (ctx, data), got {len(params)}

What it means

Error "{handler_type} must accept exactly 2 parameters (ctx, data), got {len(params)}" thrown in langchain-ai/langgraph.

Source

Thrown at libs/sdk-py/langgraph_sdk/encryption/__init__.py:64

    Args:
        fn: The handler function to validate
        handler_type: Description of the handler for error messages

    Raises:
        TypeError: If the handler is not an async function or has wrong parameter count
    """
    if not inspect.iscoroutinefunction(fn):
        raise TypeError(f"{handler_type} must be an async function, got {type(fn)}")

    sig = inspect.signature(fn)
    params = [
        p
        for p in sig.parameters.values()
        if p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD)
    ]
    if len(params) != 2:
        raise TypeError(
            f"{handler_type} must accept exactly 2 parameters "
            f"(ctx, data), got {len(params)}"
        )


class _EncryptDecorators:
    """Decorators for encryption handlers.

    Provides @encryption.encrypt.blob and @encryption.encrypt.json decorators for
    registering encryption functions.
    """

    def __init__(self, parent: Encryption):
        self._parent = parent

    def blob(self, fn: types.BlobEncryptor) -> types.BlobEncryptor:
        """Register a blob encryption handler.

View on GitHub (pinned to 38031739e5)

When it happens

Trigger: Thrown at libs/sdk-py/langgraph_sdk/encryption/__init__.py:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/a3349bd24aa0f244. Report an issue: GitHub.