langchain-ai/langchain · error · KeyError
Reference '{path}' not found.
Error message
Reference '{path}' not found. What it means
Error "Reference '{path}' not found." thrown in langchain-ai/langchain.
Source
Thrown at libs/core/langchain_core/utils/json_schema.py:41
A deep copy of the referenced object (dict or list).
Raises:
ValueError: If the path does not start with `'#'`.
KeyError: If the reference path is not found in the schema.
"""
components = path.split("/")
if components[0] != "#":
msg = (
"ref paths are expected to be URI fragments, meaning they should start "
"with #."
)
raise ValueError(msg)
out: list[Any] | dict[Any, Any] = schema
for component in components[1:]:
if component in out:
if isinstance(out, list):
msg = f"Reference '{path}' not found."
raise KeyError(msg)
out = out[component]
elif component.isdigit():
index = int(component)
if (isinstance(out, list) and 0 <= index < len(out)) or (
isinstance(out, dict) and index in out
):
out = out[index]
else:
msg = f"Reference '{path}' not found."
raise KeyError(msg)
else:
msg = f"Reference '{path}' not found."
raise KeyError(msg)
return deepcopy(out)
def _process_dict_properties(
properties: dict[str, Any],View on GitHub (pinned to e32fa9a52e)
Solutions
- Verify the '$ref' path points to an existing node in the schema (e.g. '#/definitions/X' requires a 'definitions' object containing 'X').
- Inline the referenced subschema, or fix the schema so the referenced key exists.
Example fix
schema['definitions'] = {'MyModel': {...}} # then '#/definitions/MyModel' resolves When it happens
Trigger: Raised when a JSON Schema $ref fragment path points to a location that does not exist in the schema being dereferenced.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/df43e39dcd3f7605.
Report an issue: GitHub.