langchain-ai/langchain · error · ValueError
Unsupported output parser {output_parser_type}
Error message
Unsupported output parser {output_parser_type} What it means
`_load_output_parser` only supports output parsers whose config `_type` equals `"default"` (mapped to `StrOutputParser`). Any other `_type` in the `output_parser` section of a prompt config raises `ValueError: Unsupported output parser {type}`.
Source
Thrown at libs/core/langchain_core/prompts/loading.py:147
examples = json.load(f)
elif path.suffix in {".yaml", ".yml"}:
examples = yaml.safe_load(f)
else:
msg = "Invalid file format. Only json or yaml formats are supported."
raise ValueError(msg)
config["examples"] = examples
else:
msg = "Invalid examples format. Only list or string are supported."
raise ValueError(msg) # noqa:TRY004
return config
def _load_output_parser(config: dict[str, Any]) -> dict[str, Any]:
"""Load output parser."""
if config_ := config.get("output_parser"):
if output_parser_type := config_.get("_type") != "default":
msg = f"Unsupported output parser {output_parser_type}"
raise ValueError(msg)
config["output_parser"] = StrOutputParser(**config_)
return config
def _load_few_shot_prompt(
config: dict[str, Any], *, allow_dangerous_paths: bool = False
) -> FewShotPromptTemplate:
"""Load the "few shot" prompt from the config."""
# Load the suffix and prefix templates.
config = _load_template(
"suffix", config, allow_dangerous_paths=allow_dangerous_paths
)
config = _load_template(
"prefix", config, allow_dangerous_paths=allow_dangerous_paths
)
# Load the example prompt.
if "example_prompt_path" in config:
if "example_prompt" in config:View on GitHub (pinned to e32fa9a52e)
Solutions
- Remove the `output_parser` section from the config and attach the parser in code after loading: `prompt | MyParser()`.
- Change `_type` to `"default"` if a plain string parser is acceptable.
- Migrate to `langchain_core.load.dumpd`/`dumps` + `load`/`loads` for full round-trip serialization.
Example fix
# before
# {"_type": "prompt", "template": "...",
# "output_parser": {"_type": "regex", "pattern": "..."}}
load_prompt('prompt.json') # ValueError
# after
prompt = load_prompt('prompt.json') # parser removed from config
chain = prompt | RegexParser(pattern="...") Defensive patterns
Strategy: validation
Validate before calling
op = config.get('output_parser')
if op and op.get('_type', 'default') != 'default':
del config['output_parser'] # reattach in code instead
load_prompt_from_config(config) Type guard
def is_default_output_parser(config: dict) -> bool:
op = config.get('output_parser')
return op is None or op.get('_type') == 'default' Prevention
- Keep output parsers out of serialized prompt configs; compose them in code with `|`.
- Use langchain_core.load dumpd/load when a parser must round-trip.
When it happens
Trigger: A prompt config containing `"output_parser": {"_type": "regex", ...}` or `{"_type": "structured"}`, ... loaded via `load_prompt`.
Common situations: Legacy langchain configs that serialized `RegexParser`, `PydanticOutputParser`, etc.; Hub-era prompt files with parser sections; assuming core's loader covers all legacy parser types.
Related errors
- Loading {config_type} prompt not supported
- 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.
- 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/c7b00ac7f9bec05f.
Report an issue: GitHub.