langchain-ai/langgraph · error · ValueError
types.Handler already set for
Error message
types.Handler already set for {r}, {a}. What it means
Raised by _register_handler when @auth.on tries to bind a handler to a (resource, action) pair that already has one. Each resource/action combination may hold exactly one handler; the guard prevents silent overwriting.
Solutions
- Choose a different resource or action for the new handler
- Remove or replace the existing handler registered for that (resource, action) pair
- Combine both handlers' logic into the single registered function
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/sdk-py/langgraph_sdk/auth/__init__.py:833 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/03f5a92642b4d189.
Report an issue: GitHub.
Appendix: source
Thrown at libs/sdk-py/langgraph_sdk/auth/__init__.py:833
def _register_handler(
auth: Auth,
resource: str | None,
action: str | None,
fn: types.Handler,
) -> types.Handler:
_validate_handler(fn)
resource = resource or "*"
action = action or "*"
if resource == "*" and action == "*":
if auth._global_handlers:
raise ValueError("Global handler already set.")
auth._global_handlers.append(fn)
else:
r = resource if resource is not None else "*"
a = action if action is not None else "*"
if (r, a) in auth._handlers:
raise ValueError(f"types.Handler already set for {r}, {a}.")
auth._handlers[(r, a)] = [fn]
return fn
def _validate_handler(fn: Callable[..., typing.Any]) -> None:
"""Validates that an auth handler function meets the required signature.
Auth handlers must:
1. Be async functions
2. Accept a ctx parameter of type AuthContext
3. Accept a value parameter for the data being authorized
"""
if not inspect.iscoroutinefunction(fn):
raise ValueError(
f"Auth handler '{getattr(fn, '__name__', fn)}' must be an async function. "
"Add 'async' before 'def' to make it asynchronous and ensure"
" any IO operations are non-blocking."
)View on GitHub (pinned to 38031739e5)