langchain-ai/langchain · error · ValueError
Loading {config_type} prompt not supported
Error message
Loading {config_type} prompt not supported What it means
`load_prompt_from_config` looks up the config's `_type` key in `type_to_loader_dict`, which only contains `prompt`, `few_shot`, and `chat`. Any other `_type` (or a typo) raises `ValueError: Loading {config_type} prompt not supported`. Note the loader set is intentionally small in core; richer prompt types were supported by legacy `langchain` loaders.
Source
Thrown at libs/core/langchain_core/prompts/loading.py:80
allow_dangerous_paths: If `False` (default), file paths in the
config (such as `template_path`, `examples`, and
`example_prompt_path`) are validated to reject absolute paths
and directory traversal (`..`) sequences. Set to `True` only
if you trust the source of the config.
Returns:
A `PromptTemplate` object.
Raises:
ValueError: If the prompt type is not supported.
"""
if "_type" not in config:
logger.warning("No `_type` key found, defaulting to `prompt`.")
config_type = config.pop("_type", "prompt")
if config_type not in type_to_loader_dict:
msg = f"Loading {config_type} prompt not supported"
raise ValueError(msg)
prompt_loader = type_to_loader_dict[config_type]
return prompt_loader(config, allow_dangerous_paths=allow_dangerous_paths)
def _load_template(
var_name: str, config: dict[str, Any], *, allow_dangerous_paths: bool = False
) -> dict[str, Any]:
"""Load template from the path if applicable."""
# Check if template_path exists in config.
if f"{var_name}_path" in config:
# If it does, make sure template variable doesn't also exist.
if var_name in config:
msg = f"Both `{var_name}_path` and `{var_name}` cannot be provided."
raise ValueError(msg)
# Pop the template path from the config.
template_path = Path(config.pop(f"{var_name}_path"))
if not allow_dangerous_paths:View on GitHub (pinned to e32fa9a52e)
Solutions
- Change `_type` to one of the supported values: `prompt`, `few_shot`, or `chat`.
- Rebuild the prompt programmatically (e.g. `PromptTemplate.from_template(...)` or `ChatPromptTemplate.from_messages(...)`) and serialize with `dumpd`/`dumps` from `langchain_core.load` instead.
- If the config came from the deprecated Hub format, re-create it on LangSmith Hub and pull from there.
Example fix
# before
# config.json: {"_type": "prompt_with_format", "template": "Hi {name}"}
load_prompt('config.json') # ValueError
# after
# config.json: {"_type": "prompt", "template": "Hi {name}", "input_variables": ["name"]}
load_prompt('config.json') Defensive patterns
Strategy: validation
Validate before calling
import json
SUPPORTED = {'prompt', 'few_shot', 'chat'}
config = json.loads(Path('prompt.json').read_text())
if config.get('_type', 'prompt') not in SUPPORTED:
raise ValueError(f"unsupported _type {config.get('_type')!r}; expected one of {SUPPORTED}")
load_prompt('prompt.json') Type guard
def is_supported_prompt_type(config: dict) -> bool:
return config.get('_type', 'prompt') in {'prompt', 'few_shot', 'chat'} Prevention
- Validate `_type` against the supported set when ingesting external prompt files.
- Prefer langchain_core.load.dumpd/load serialization for anything beyond the three legacy types.
When it happens
Trigger: Loading a config JSON with `"_type": "prompt_with_format"`, `"_type": "pipeline"`, or any string not in {prompt, few_shot, chat}. Also triggered when `_type` is missing — it defaults to `prompt` only via a warning, but an explicit unknown value always fails.
Common situations: Loading prompt files exported from old langchain versions or the Hub that used extended types; hand-written configs with guessed type names; team configs that assumed legacy loader support.
Related errors
- Both `{var_name}_path` and `{var_name}` cannot be provided.
- Unsupported template file format: '{resolved_path.suffix}'.
- Invalid examples format. Only list or string are supported.
- Unsupported output parser {output_parser_type}
- Only one of example_prompt and example_prompt_path should be
AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14).
Data as JSON: /api/errors/fb3e71f2dd511840.
Report an issue: GitHub.