Skip to content

fix: avoid crash when jekyll-archives.layouts is not a hash#186

Open
wwenrr wants to merge 1 commit into
jekyll:masterfrom
wwenrr:fix/181-handle-non-hash-layouts
Open

fix: avoid crash when jekyll-archives.layouts is not a hash#186
wwenrr wants to merge 1 commit into
jekyll:masterfrom
wwenrr:fix/181-handle-non-hash-layouts

Conversation

@wwenrr
Copy link
Copy Markdown

@wwenrr wwenrr commented Apr 1, 2026

Summary

This PR fixes a configuration edge-case that can crash archive generation when jekyll-archives.layouts is set to a non-Hash value (for example, a string due to typo or misconfiguration).

Instead of calling dig unconditionally, layout/permalink lookups are now guarded to only index when the nested config is actually a Hash, with graceful fallback to the default layout.

Changes

  • Updated Jekyll::Archives::Archive#layout to safely handle malformed layouts config.
  • Updated Jekyll::Archives::Archive#template similarly for defensive consistency.
  • Added regression test context to verify malformed layouts no longer raises and archive pages are still generated with fallback layout.

Manual verification

Ran tests in Docker (Ruby 3.3):

docker run --rm -v "$PWD":/work -w /work ruby:3.3 bash -lc "bundle install && bundle exec ruby -Itest test/test_jekyll_archives.rb"

Result:

  • 22 runs, 54 assertions, 0 failures, 0 errors, 0 skips

Fixes #181

Handle malformed jekyll-archives.layouts config defensively by
falling back to the default layout key instead of calling dig on
a non-Hash value.

Add regression coverage for malformed layouts config to ensure
archive generation does not crash.

Fixes jekyll#181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

String does not have #dig method (TypeError)

1 participant