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

Error when loading certain author pages #2067

Closed
Tak opened this issue Mar 28, 2022 · 1 comment
Closed

Error when loading certain author pages #2067

Tak opened this issue Mar 28, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Tak
Copy link
Contributor

Tak commented Mar 28, 2022

Describe the bug
When loading certain author pages, e.g. https://reading.taks.garden/author/27 , Bookwyrm gives an internal server error.

Discussion from matrix:

hey, I have an author on my instance that gives an internal server error when I try to load their page - the relevant part of the stack trace seems to be:

  File "/usr/local/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.9/site-packages/django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/app/bookwyrm/templatetags/shelf_tags.py", line 40, in active_shelf
    f"active_shelf-{user.id}-{book.id}",
AttributeError: 'NoneType' object has no attribute 'id'

I tried adding some early check/return in shelf_tags.py, but eventually I get another error instead, so now I'm giving up 😀

  File "/usr/local/lib/python3.9/site-packages/django/template/defaulttags.py", line 449, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/usr/local/lib/python3.9/site-packages/django/urls/base.py", line 86, in reverse
    return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 698, in _reverse_with_prefix
    raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'reading-status' with arguments '('want', '')' not found. 1 pattern(s) tried: ['reading-status/(?P<status>want|start|finish)/(?P<book_id>\\d+)/?$']

huh -- it sounds like there's a nonexistant book trying to display on the author page. It could be that there's a work with no editions 🤔

I'll try to dig through the db entries for the associated books and see if anything jumps out

I think models.Work.objects.filter(editions__isnull=True).count() will tell you if there are works without editions

>>> print(Work.objects.filter(editions__isnull=True).count())
64

I've been meaning to add some automated tasks that clean up book data that gets into a bad state. And I think I know how to resolve your author page error
I'm trying to replicate the error locally and works without editions don't seem to be the problem, so I'm still not sure what's up. Can you open a github issue for it?

Additional context:
The local author entry for the affected author:

>>> serializers.serialize('json', Author.objects.filter(id=27))
'[{"model": "bookwyrm.author", "pk": 27, "fields": {"created_date": "2021-09-22T09:27:34.115Z", "updated_date": "2021-09-22T09:27:34.117Z", "remote_id": "https://reading.taks.garden/author/27", "origin_id": "https://bookwyrm.social/author/149", "openlibrary_key": "OL7482725A", "inventaire_id": null, "librarything_key": "", "goodreads_key": "15045277", "bnf_id": null, "viaf": "75149617064103752411", "wikidata": null, "asin": null, "search_vector": null, "last_edited_by": null, "wikipedia_link": "", "isni": null, "gutenberg_id": null, "born": null, "died": null, "name": "Sarah Gailey", "aliases": "[]", "bio": "Hugo award winner Sarah Gailey lives and works in California. Their nonfiction has been published by dozens of venues internationally including Locus and the Boston Globe. Their fiction has been published internationally in over six different languages. Their debut novel, Magic for Liars, was an LA Times bestseller. Their most recent novel, The Echo Wife, is available now everywhere books are sold. You can find links to their work at sarahgailey.com and on social media at @gaileyfrey.\\r\\n\\r\\nImage ©Allan Amato 2019."}}]'
@Tak Tak added the bug Something isn't working label Mar 28, 2022
@mouse-reeve
Copy link
Member

I believe this was fixed by #2905

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants