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
Guard against type error in absolute url #6280
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks solid. 👍
This kind of error is nice; it provides the user with the information that the url they provided is complete bogus – "whoops, gotta fix that!" It calls them to action in a way that suppressing this might not. Do you agree that we're losing value there?
@parkr see the bug report in jekyll/jekyll-feed#178. Given that it took some of Jekyll's top contributors 3+ weeks to determine the root cause of the opaque An alternative approach would be a more descriptive error with page/post-level backtrace, but that's beyond what I'm able to invest right now. |
@jekyllbot: merge +fix |
Backporting to 3.5 targeting a 3.5.2. |
Backport to 3.5: Guard against type error in absolute url (#6280)
If a user sets an
image
hash in a post's YAML front matter, and that hash does not contain apath
key, this line in Jekyll Feed will pass the full image hash to theabsolute_url
filter.Via #6185 and #6253 we normalize the
baseurl
andsite.url
inputs, but we don't normalize the argument passed to theabsolute_url
filter (we normalize the input passed torelative_url
), meaning if you pass anything other than a string, it method will raise aTypeError
when it tries to determine if the non-url is absolute.This PR calls an explicit
to_s
on the input, seeking to return a malformed URL, rathering than breaking the build (which is often opaque due to a single post missing apost.image.path
field raising an error in generatingfeed.xml
).