Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liquid Exception comparison of Array with Array failed #406

Closed
patrik-u opened this issue Aug 7, 2020 · 8 comments
Closed

Liquid Exception comparison of Array with Array failed #406

patrik-u opened this issue Aug 7, 2020 · 8 comments
Labels

Comments

@patrik-u
Copy link

patrik-u commented Aug 7, 2020

I have a github pages site which suddenly started generating generic errors whenever I committed changes (been a while since i committed, last was in may):

The page build failed for the `master` branch with the following error:

Page build failed. For more information, see https://docs.github.com/en/github/working-with-github-pages/troubleshooting-jekyll-build-errors-for-github-pages-sites#troubleshooting-build-errors.

Wasn't very helpful, so contacted github support and they saw the following error in their logs:

Liquid Exception: Liquid error (/tmp/jekyll-remote-theme-20200807-6-1r5fb81/_includes/nav.html line 9): comparison of Array with Array failed included in /_layouts/default.html

Not very helpful so I after some trial and error getting the site to compile locally I managed to replicate the error. After more trial and error I found that if files under _post/ starts with numbers it caused the error to happen. Removing them and the error goes away. Heureka! So I did the changes committed it to my github pages and...

Page build failed.

tenor

So I can no longer reproduce the error locally, and build fails on github pages. I've contacted the support and maybe there is a different error this time.

@patrik-u patrik-u added the bug label Aug 7, 2020
@pdmosses
Copy link
Contributor

pdmosses commented Aug 8, 2020

@patrik-u if you'd like us to look at this, could you create a small test repository that exhibits the issue, and post a link to it?

BTW, you refer to _post/, but the directory Jekyll uses for posts is named _posts/, and Jekyll seems to expect the file names to start with the year.

@patrik-u
Copy link
Author

patrik-u commented Aug 8, 2020

That was a typo, the folder is indeed _posts/

@patrik-u
Copy link
Author

patrik-u commented Aug 8, 2020

Added a repository here:

https://github.com/patrik-u/just-the-docs-issue

It doesn't render exactly as the github pages site (not sure why). You can see the error when running and it goes away if you rename the files in _posts/ or remove the folder.

@pdmosses
Copy link
Contributor

pdmosses commented Aug 8, 2020

Thanks, that helped. I don't understand why the sorting fails, but as a workaround, try
adding the attached version of nav.html to _includes, and adding nav_exclude: true to all files in _posts.

nav.html.zip

@patrik-u
Copy link
Author

patrik-u commented Aug 8, 2020

Thanks that solved it for me.

@pdmosses
Copy link
Contributor

pdmosses commented Aug 8, 2020

I'll submit a PR with that update to nav.html.

The Jekyll failure was due to nav.html including pages with nav_exclude: true when sorting unordered pages on their titles. Your 404.md has the following in its front matter:

title: 404
permalink: /404.html
nav_exclude: true

Jekyll treats 404 as a number, and sorting fails when comparing numbers with strings...

The simplest way to make your repository work (without the fix to nav.html) is simply to change title: 404 in 404.md to title: "404". It isn't necessary to add nav_exclude: true to the files in _posts.

@patrik-u
Copy link
Author

patrik-u commented Aug 8, 2020

Thanks, that worked.

@pdmosses pdmosses changed the title Files under _post/ starting with a number generates Liquid Exception comparison of Array with Array failed included in /_layouts/default.html Liquid Exception comparison of Array with Array failed Aug 8, 2020
@pdmosses
Copy link
Contributor

pdmosses commented Aug 8, 2020

The reported Liquid exception is due to sorting an array that contains mixed types of values. In this case, the title of one file was parsed as a number; but it can also happen when nav_order fields are both numbers and strings.

Jekyll/Liquid error reports can be confusing, and the theme code should try to ensure that they never arise.

@patrik-u patrik-u closed this as completed Aug 8, 2020
pdmosses added a commit to pdmosses/just-the-docs that referenced this issue Aug 10, 2020
Pages with `nav_exclude: true` were included when sorting on `title` or `nav_order`. That could cause build failures when the type of value of the field differs from that on other pages, as reported in just-the-docs#406.

Pages with `nav_exclude: true` or no `title` are never displayed in the navigation, so removing them from `pages_list` cannot break existing sites. This change also allows the removal of some tests in the code. (The indentation of the code should now be adjusted, but that has been deferred, to restrict the size of the diff for review.)

For testing, the title of `404.html` has been changed to the number `404`,  the page `docs/untitled-test.md`  has been added, and `nav_sort_order` has been set to `case_sensitive`. Those updates give build failures with the current version of `_includes/nav.html`, but not after the suggested changes.

It will still be possible for build failures to occur due to sorting fields of *non-excluded* pages with differing types of values (e.g., `nav_order`a mixture of numbers and strings). To make the code completely safe will require relatively complicated changes,.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants