langchain-ai/langgraph · error · TypeError
Expected str, datetime.tzinfo, or None for timezone, got {ty
Error message
Expected str, datetime.tzinfo, or None for timezone, got {type(tz).__name__} What it means
Error "Expected str, datetime.tzinfo, or None for timezone, got {type(tz).__name__}" thrown in langchain-ai/langgraph.
Source
Thrown at libs/sdk-py/langgraph_sdk/_shared/utilities.py:158
otherwise ``tzname(None)`` is used.
- ``None`` (returned as ``None``)
"""
if tz is None or isinstance(tz, str):
return tz
if isinstance(tz, tzinfo):
# ZoneInfo objects have a .key attribute with the IANA name
key = getattr(tz, "key", None)
if isinstance(key, str):
return key
# Fall back to tzname for fixed-offset timezones like datetime.timezone.utc
name = tz.tzname(None)
if name is not None:
return name
raise ValueError(
f"Cannot determine timezone name from {tz!r}. "
"Use a zoneinfo.ZoneInfo instance or pass a string like 'America/New_York'."
)
raise TypeError(
f"Expected str, datetime.tzinfo, or None for timezone, got {type(tz).__name__}"
)
def _default_port(scheme: str) -> int:
return 443 if scheme == "https" else 80
def _validate_reconnect_location(base_url: httpx.URL, location: str) -> str:
"""Validate that a reconnect Location URL is same-origin as the base URL.
Raises ValueError if the Location header points to a different origin
(scheme + host + port), which would leak credentials to an external server.
"""
parsed = urlparse(location)
# Relative URLs are safe — they resolve against the base
if not parsed.scheme and not parsed.netloc:
return locationView on GitHub (pinned to 38031739e5)
When it happens
Trigger: Thrown at libs/sdk-py/langgraph_sdk/_shared/utilities.py:158 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/7cd795f3c4075b5b.
Report an issue: GitHub.