langchain-ai/langgraph · error · TypeError

run_id must be a UUID or None

Error message

run_id must be a UUID or None

What it means

_copy_graph_manager validates the run_id passed when cloning a callback manager: after the _MISSING sentinel and None cases, only UUID instances are acceptable, so anything else (str, int, etc.) triggers TypeError.

Solutions

  1. Pass a uuid.UUID instance or None for run_id.
  2. Convert string IDs with uuid.UUID(value) before passing.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at libs/langgraph/langgraph/callbacks.py:204 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/d1e3a819ce2d2d6c. Report an issue: GitHub.

Appendix: source

Thrown at libs/langgraph/langgraph/callbacks.py:204

        )
    if isinstance(callbacks, GraphCallbackHandler):
        return cls((callbacks,), run_id=run_id)
    if isinstance(callbacks, (str, bytes)) or not isinstance(callbacks, Sequence):
        raise TypeError("callbacks must be a handler, sequence, or manager")
    return cls(_filter_graph_handlers(list(callbacks)), run_id=run_id)


def _copy_graph_manager(
    manager: _GraphCallbackManager | _AsyncGraphCallbackManager,
    cls: type[_GraphManagerT],
    run_id: UUID | None | object,
) -> _GraphManagerT:
    resolved_run_id: UUID | None
    if run_id is _MISSING:
        resolved_run_id = manager.run_id
    else:
        if run_id is not None and not isinstance(run_id, UUID):
            raise TypeError("run_id must be a UUID or None")
        resolved_run_id = run_id

    return cls(
        handlers=_filter_graph_handlers(manager.handlers),
        inheritable_handlers=_filter_graph_handlers(manager.inheritable_handlers),
        parent_run_id=manager.parent_run_id,
        tags=manager.tags.copy(),
        inheritable_tags=manager.inheritable_tags.copy(),
        metadata=manager.metadata.copy(),
        inheritable_metadata=manager.inheritable_metadata.copy(),
        run_id=resolved_run_id,
    )


class _GraphCallbackManager(BaseCallbackManager):
    """Sync dispatcher for graph lifecycle events."""

    run_id: UUID | None

View on GitHub (pinned to 38031739e5)