Neaten up YAML parsing errors #591

merged 1 commit into from Dec 16, 2012


None yet

10 participants


At least when using Octopress, Jekyll gives an uninformative error message and a stack trace when it finds invalid YAML front matter. This change adds the filename to the output and produces a cleaner error message.

After Change

(<unknown>): couldn't parse YAML at line 9 column 0 in /Volumes/HOME/neil/octopress/source/_posts/free/2011-11-23-blackball-godaddy.html

Before Change

/usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/psych.rb:155:in `parse': (<unknown>): couldn't parse YAML at line 9 column 0 (Psych::SyntaxError)
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/psych.rb:155:in `parse_stream'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/psych.rb:125:in `parse'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/1.9.1/psych.rb:112:in `load'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/convertible.rb:33:in `read_yaml'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/post.rb:39:in `initialize'
    from /Volumes/HOME/neil/octopress/plugins/preview_unpublished.rb:24:in `new'
    from /Volumes/HOME/neil/octopress/plugins/preview_unpublished.rb:24:in `block in read_posts'
    from /Volumes/HOME/neil/octopress/plugins/preview_unpublished.rb:21:in `each'
    from /Volumes/HOME/neil/octopress/plugins/preview_unpublished.rb:21:in `read_posts'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:128:in `read_directories'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:98:in `read'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:38:in `process'
    from /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/bin/jekyll:250:in `<top (required)>'
    from /usr/local/Cellar/ruby/1.9.3-p0/bin/jekyll:19:in `load'
    from /usr/local/Cellar/ruby/1.9.3-p0/bin/jekyll:19:in `<main>'
mkaz commented Aug 21, 2012

Thank you! I was having a bear trying to track down the issue, and this patch was exactly what I needed.


Not a problem @mkaz - it's still a one-off until @mojombo and company (hint hint :-) to merge the pull request.

For the love of God please merge this pull request. Thanks for this patch @Neil-Smithline


You're welcome @toddynho. though your wishes may not be enough to pull the fix.

Being it's so tiny you may just want to grab it and merge it into your installed code.

+1 this merge request.

ckreutz commented Sep 28, 2012

+1 Thanks a lot. That parsing error message was so annoying before.

Wonder why this is not merged yet?

mattr- commented Nov 25, 2012

@Neil-Smithline Hi, I'd like to merge this to mattr-/jekyll@next but there are some whitespace errors. Would you be willing to fix the whitespace errors and update this pull request? git diff --color should show them to you. A test would be nice as well, but isn't required.


I am ready, willing, but not-so able to update the pull request @mattr-

I'm not a Ruby programmer. I only play one on TV. So I have no idea what a "whitespace error" is but feel confident Google can help me on that.

But writing a test... Can you point me in the right direction? I'm not sure how to get started on that one.

PS: does the next branch imply that this is on its way to graduating into the official Jekyll release?

mattr- commented Nov 25, 2012

No worries then. I can take care of the remaining changes.

I hope that next does make its way into jekyll eventually. my goal is to put together a branch that would be a good next release of Jekyll and then attempt to get it merged. 😄


@mattr- can you point me to the changes and test once you've written them? I'd like to see what I'm missing.

This is corporate-ish-ly slow :|


@kingsidharth I have to agree. That said, Github is a wonderful site that predominantly offers free services, and, IMO, it and the Ruby crowd have revitalized open source. Not since the 80's when Stallman was alternating between highly effective coding and insane rantings have I seen open source be as influential as it is today.

Also, every time I submit a pull request these Ruby types want a test. It is a pain in my butt but it makes me dance with glee. Every check-in should have a test and, to these Ruby types, that is just standard. In some nerd-to-nerd way, I love them all!

None of that changes the fact that this was a bug that, when you ran into it, was terribly hard to deal with. I used to do binary searches on my files, Jekyll-izing half of them to see where the problem was and then splitting that up again to help me track down the file. More than once I had several problems and that was a nightmare.

I also feel strongly that proper error handling isn't an add-on. It must be part of the application.

Still, with free software and lots of other tasty morsels I can deal with a slow response to a pull request.

My current concern is that @mattr- won't be able to get his Jekyll mods pulled into the main line. I'd hate to see a series of improvements not get pulled and, even worse, see the Jekyll codebase fork.

@mattr- if you could post on this pull request any status changes to your mods that would be great. Especially if you get it pulled into the main line or if you are having trouble and want an extra voice or two behind you.

  • Neil


I hear you. Test writing is good but I'd love someone helping out if you can't write one.
Anyway, I expected better of Ruby community to say the least.

mattr- commented Nov 25, 2012

There are a some things about this conversion that I feel like I need to clarify.

The first is that I don't work for GitHub. I've decided to take up working on Jekyll in my spare time because it's a project that I use and care about being maintained. I don't yet have access to push to the repository, merge pull requests, or close issues.

Second, if people are unable to incorporate any of the suggestions I provide in their pull requests, then I'm taking care of doing them myself. This is because I'm putting together what I think would be useful to see in a next version of Jekyll and maintaining that over at mattr-/jekyll so that I can, hopefully, submit a single pull request and have it merged.

@Neil-Smithline mattr-/jekyll@801a4d6 contains the whitespace change I made. I haven't added a test for your change yet. I'll let you know when I do. Once your changes have actually been merged into master, this pull request will be closed.


Thanks for the clarification @mattr- If you have trouble getting your mods pulled into the Jekyll master, you may want to put a note on this pull request. It seems to have several interested parties (me included) who may lobby for you.

Thx again

mojombo commented Dec 16, 2012

@Neil-Smithline Thank you so much for the patch. I agree with you 100% on good error reporting being a built in requirement of good software.

Sorry for the delay. I'm working on putting a team together to foster Jekyll to new and more awesome heights. Do not abandon hope! @mattr-, I'll be in touch. Will merge this in a minute.

@mojombo mojombo merged commit 3904fd9 into jekyll:master Dec 16, 2012
mattr- commented Dec 19, 2012

@mojombo welcome back. ❤️ feel free to get in touch with me whenever you can. 😄

@stereobooster stereobooster commented on the diff Dec 30, 2012
@@ -38,7 +38,11 @@ def initialize(site, source, dir, name)
self.categories = dir.split('/').reject { |x| x.empty? }
- self.read_yaml(@base, name)
stereobooster Dec 30, 2012 Contributor

page and layout using read_yaml too

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.