Skip to content

Debugging YAML Parse Errors

In case something goes wrong and you get errors like this:

ValueError: YAML error found in file config/config.yaml. Line 22,Position 10: mapping values are not allowed here
  in "config/config.yaml", line 22, column 10

This means that the error might be at line 22, just before it or shortly after it. Sometimes it is tricky to tell whats wrong when one space is off. A good editor might help but it might be still hard to spot the exact point.

Install an IDE

We recommend the MPF language server with a supported IDE for that.

Install the extension

If you are struggling to find the problem you can reformat your file using ruamel.yaml. To do that you first need to install the ruamel.yaml.cmd extension:

pip3 install ruamel.yaml.cmd==0.2

Make a backup

Before you continue: Make a backup of your machine config. Seriously, do it! Even better, use git and commit right now!

Reformatting YAML files

After that you can reformat single files using the round-trip command. For example if you want to reformat your_file.yaml first check the changes it would make:

yaml round-trip your_file.yaml

If that looks alright perform them by adding the --save flag:

yaml round-trip --save your_file.yaml

This will keep comments but reformat all your indents to two spaces per level. It should be easier now to spot the problem.

Reformat Your Config Using MPF format

Run mpf format on your config. See Format And Lint Config Files for details.

What if it did not help?

If this did not help you can ask in the mpf-users Google group. Please post the full error message, your log file and the relevant config file.


Something missing or wrong? You can fix it!

This website is edited by people like you! Is something wrong or missing? Is something out of date, or can you explain it better?

Please help us! You can fix it yourself and be an official "open source" contributor!

It's easy! See our Beginner's guide to editing the docs.

Page navigation via the keyboard: < >

You can navigate this site via the keyboard. There are two modes:

General navigation, when search is not focused:

  • F , S , / : open search dialog
  • P , , : go to previous page
  • N , . : go to next page

While using the search function:

  • Down , Up : select next / previous result
  • Esc , Tab : close search
  • Enter : go to highlighted page in the results