-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Better logging if writing a tag/catetory/author page fails #3266
base: main
Are you sure you want to change the base?
Conversation
Because, slug is empty and depending on >>> from pelican.urlwrappers import Tag
>>> from pelican.settings import DEFAULT_CONFIG
>>> t = Tag('**', DEFAULT_CONFIG)
>>> t.slug
'' And that's because Off the top of my head, I cannot think of any reason for wanting an empty slug intentionally. So if no objections, we could error for empty slug. |
I've updated it as per your comments! This is the current message:
I have it throw a warning (rather than a critical error) if the slug is invalid, but throws the "regular" critical error if it's run into some other problem. I've "un- pre- formatted" the log messages, and dropped the Overall, it makes sense that slugify would strip out questionable character; I was just annoyed that Pelican would break but not really tell me what was wrong or how to fix it; I hope this explains how to fix the issue to the next user. |
e675806
to
4909657
Compare
I've added a warning when trying to generate a slug from a name that won't give a valid slug, and downgraded the former warning to an INFO message. So the displayed messages (when run with
|
if not tag.slug: | ||
logger.info( | ||
'Tag "%s" has an invalid slug; skipping writing tag page...', | ||
tag, | ||
extra={"limit_msg": "Further tags with invalid slugs."}, | ||
) | ||
continue |
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.
With empty slugs already generating warnings, is this special case necessary anymore? Why not just do the else
block?
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.
I think it's helpful to still keep this, because it makes it very explicity what Pelican is (or isn't doing), and it's not entirely obvious that an invalid slug would keep the page from being generated.
Also, it mirrors the logging for all the pages that are written.
Hi @avaris ! This seems to have been lost in the shuffle. Do you want me to remove the logging (of the non-generated pages), or is it good to merge as is? Thanks! |
Hey @avaris ! Let me know if anything more is needed to merge this! Thanks! |
Apologies, offline life get in the way of things. I'll try to get back to this ASAP. |
No worries at all. My offline life has kept me from anything Pelican-related for the last couple months too... |
Add a short logging message if for some reason an invalid tag is provided, and Pelican instead tries to overwrite the index page.
Before:
After:
(For some reason, the tag
**
is mapped onto the index page. Perhaps that is another issue that should be fixed...)Fix is applied when writing Tag, Category, and Author pages. Let me know if it should be added other places.
Pull Request Checklist