Posts with invalid dates result in unhelpful error messages #4375

Closed
benbalter opened this Issue Jan 19, 2016 · 6 comments

Projects

None yet

3 participants

@benbalter
Contributor

Steps to reproduce:

  1. In an empty folder, create a _posts subdirectory, an add 2016-01-01-test.md
  2. In that post, add an invalid date in the YAML front matter, e.g., date: tuesday
  3. jekyll build

Expected

Site would yell at me, but still builds

Actual

  • jekyll 3.0.1 | Error: undefined methodeach' for nil:NilClass`
  • jekyll 3.1.0.pre.rc2 | Error: undefined methodstrftime' for "invalid-date":String`

The same is true of other non-date values.

@benbalter benbalter added the Bug label Jan 19, 2016
@parkr parkr self-assigned this Jan 19, 2016
@parkr
Member
parkr commented Jan 19, 2016

Site would yell at me, but still builds

I'm not sure it should build – we generally like to make things error out entirely. This message is sadly quite unhelpful but we could tidy it up. I am of the opinion that failing loudly is better here than letting the build succeed.

@benbalter benbalter changed the title from Build fails if any post has an invalid date to Posts with invalid dates result in unhelpful error messages Jan 19, 2016
@benbalter
Contributor

To note, the same also happens with a post of _posts/2016-25-35-test.md.

You're right, it should be an error, not a warning. That was also the behavior pre-3.0, which responded with:

  • /Post '_posts\/(.*\d+-\d+-\d+-.*)' does not have a valid date in the YAML front matter./
  • /Post '_posts\/(.*\d+-\d+-\d+-.*)' does not have a valid date in the filename./

Edit Renamed the issue to properly represent the problem based on pre 3.0 behavior.

Edit2: swapped error for warning.

@parkr
Member
parkr commented Jan 19, 2016

@benbalter I'll fix this up and publish a v3.0.2 with any other bugs you may find. Hoping to have v3.1.0 out the door this week, too.

@envygeeks
Member

What happens when somebody messes up the date, doesn't notice the warning because it let it built, publishes their site to Github, or otherwise, messes up their SEO, and comes and blames us because we didn't throw like we should? The principle of all good programming is to throw, that's no different than an app, the difference is that instead of throwing with a trace we throw a message at them and refuse the built.

@parkr
Member
parkr commented Jan 19, 2016

You're right, it should be a warning, not an error.

I mean to say that it should be an error, not that it should just warn. The first sentence of my comment was a little confusing!

@parkr parkr added this to the 3.0.2 milestone Jan 19, 2016
@benbalter
Contributor

I mean to say that it should be an error, not that it should just warn. The first sentence of my comment was a little confusing!

Nah, I knew what you meant. I just swapped 'em in my head. Updated my comment. I agree with you. Errors all around.

@parkr parkr closed this Jan 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment