langchain-ai/langgraph · error · ValueError
Global handler already set.
Error message
Global handler already set.
What it means
Raised by the internal _register_helper when @auth.on (resource="*", action="*") registers a second catch-all authorization handler. One global wildcard handler is allowed; a second would be unreachable or ambiguous, so registration fails fast.
Solutions
- Scope the additional handler to a specific resource and/or action instead of the wildcard, e.g. @auth.on("runs", "create")
- Remove the duplicate global handler and consolidate the logic
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/sdk-py/langgraph_sdk/auth/__init__.py:827 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/e0aeac0982c4944a.
Report an issue: GitHub.
Appendix: source
Thrown at libs/sdk-py/langgraph_sdk/auth/__init__.py:827
for action in action_list:
_register_handler(self._auth, resource, action, handler)
return handler
return decorator
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
"""View on GitHub (pinned to 38031739e5)