langchain-ai/langgraph · error · ValueError
Refusing to follow cross-origin reconnect Location
Error message
Refusing to follow cross-origin reconnect Location: {location!r} (origin {loc_origin}) does not match base URL origin {base_origin} What it means
SSRF protection in the reconnect-URL validator: the server's Location header on a stream reconnect points at a different origin (scheme/host/port) than the base URL. Following it would send credentials/events to an attacker-controllable host, so the client refuses the redirect.
Solutions
- Verify the deployment's reconnect endpoint stays on the same origin as the base URL
- Fix a misconfigured proxy/load balancer rewriting Location to an external host
- If the redirect is legitimately same server, ensure scheme and port (including defaults) match exactly
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/sdk-py/langgraph_sdk/_shared/utilities.py:190 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/305ac3feefcef10b.
Report an issue: GitHub.
Appendix: source
Thrown at libs/sdk-py/langgraph_sdk/_shared/utilities.py:190
"""
parsed = urlparse(location)
# Relative URLs are safe — they resolve against the base
if not parsed.scheme and not parsed.netloc:
return location
# Compare origin components (normalize default ports to avoid mismatches)
base_scheme = str(base_url.scheme)
base_origin = (
base_scheme,
str(base_url.host),
base_url.port or _default_port(base_scheme),
)
loc_origin = (
parsed.scheme,
parsed.hostname or "",
parsed.port or _default_port(parsed.scheme),
)
if base_origin != loc_origin:
raise ValueError(
f"Refusing to follow cross-origin reconnect Location: {location!r} "
f"(origin {loc_origin}) does not match base URL origin {base_origin}"
)
return location
def _provided_vals(d: Mapping[str, Any]) -> dict[str, Any]:
return {k: v for k, v in d.items() if v is not None}
def _quote_path_param(value: Any) -> str:
"""Encode a value for safe interpolation into a request path segment.
Path segments are encoded with ``safe=""`` so that ``/`` and other reserved
characters are escaped. Standalone dot-segments (``.`` and ``..``) are also
encoded because some URL-handling stacks (including ``httpx``) collapse
them client-side as relative-path traversal before transmission. The value
is coerced to ``str`` so callers can pass ``uuid.UUID`` and similar typesView on GitHub (pinned to 38031739e5)