Skip to content

YAML Parsing Error from LLM Output in Flow Execution #87

Open
@lazarkanelov

Description

@lazarkanelov

I have observed a crash during YAML parsing, due to malformed YAML generated by the LLM - Gemini 2.5 Pro. The following traceback is observed:

yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 2, column 158:
     ... all the details about your order: what dish you want (service/op ...

This error occurs when the YAML loader (yaml.safe_load) tries to parse a response from the LLM that contains a colon (:) in the value field, but the value is not quoted. This causes PyYAML to interpret it as an invalid mapping.

Full Traceback

File "C:\Dev\PocketFlow-Tutorial-Codebase-Knowledge\main.py", line 97, in <module>
  main()
File "C:\Dev\PocketFlow-Tutorial-Codebase-Knowledge\main.py", line 94, in main
  tutorial_flow.run(shared)
File "...\pocketflow\__init__.py", line 16, in run
  return self._run(shared)
...
File "...\nodes.py", line 181, in exec
  abstractions = yaml.safe_load(yaml_str)
...
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 2, column 158:
     ... all the details about your order: what dish you want (service/op ...

Root Cause
• The LLM returns a YAML snippet with unquoted colons inside text values which breaks YAML’s expectation of key: value pairs.
• yaml.safe_load() fails because it interprets the second colon as the start of a new mapping.

Impact
• The flow crashes during execution, and retries do not recover.

Environment
• Windows environment
• Python environment under .venv
• PyYAML version from standard pip install

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions