bookwyrm-social / bookwyrm

Social reading and reviewing, decentralized with ActivityPub
http://joinbookwyrm.com/
Other
2.24k stars 264 forks source link

Issue manually creating book with cover image and importing books via search from other instances and databases #3351

Open marcusyoung opened 5 months ago

marcusyoung commented 5 months ago

Describe the bug More often than not importing from other catalogues in search fails with the error "Server Error Something went wrong! Sorry about this." The same error occurs when creating a new book with a cover image, or attaching an image to an existing book.

Expected behavior Book to be import

Instance ramblingreaders.org

Additional context Problem only arose after upgrade from 0.6.6 to 0.7.3

mouse-reeve commented 5 months ago

Is it possible to get a stack trace on any of these? They should be available in Flower or the celery logs

dato commented 5 months ago

I think I've diagnosed this, and will be submitting a fix shortly.

It's due to #3273 allowing pages to be strings, whereas one of the pure_content() method still assumes they're int:

  File ".../bookwyrm/models/status.py", line 398, in _format_position
    return f"pp. {beg}-{end}" if end > beg else f"p. {beg}"
TypeError: '>' not supported between instances of 'int' and 'str'
dato commented 5 months ago

I think I've diagnosed this,

Whoops, this message was meant for #3352 instead..

marcusyoung commented 5 months ago

Is it possible to get a stack trace on any of these? They should be available in Flower or the celery logs

I'm not sure how to get to the Flower or celery logs (dockerless install). I have this in the bookwyrm service logs for a failed import. Is that on any use?

Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]: OK: /book/378729/s/water-in-plain-sight
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]: Traceback (most recent call last):
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:   File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:     response = get_response(request)
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:   File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 204, in _get_response
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:     response = response.render()
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:   File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 105, in render
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:     self.content = self.rendered_content
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:   File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 83, in rendered_content
Apr 08 22:51:16 izzy.graspit.co.uk gunicorn[11256]:     return template.render(context, self._request)
marcusyoung commented 5 months ago

@mouse-reeve it appears this issue is also preventing any new books from being created. In particular if a cover image is added to the book. Or if attempt to add a cover to an existing book.

marcusyoung commented 5 months ago

@mouse-reeve Do you think there would be any implications if I checkout version 0.7.2 instead? Any database changes in 0.7.3 that would cause an issue?

Minnozz commented 5 months ago

@mouse-reeve Do you think there would be any implications if I checkout version 0.7.2 instead? Any database changes in 0.7.3 that would cause an issue?

Before checking out 0.7.2, you can revert the database migrations included in 0.7.3:

./bw-dev migrate bookwyrm 0192_sitesettings_user_exports_enabled
marcusyoung commented 5 months ago

@mouse-reeve Do you think there would be any implications if I checkout version 0.7.2 instead? Any database changes in 0.7.3 that would cause an issue?

Before checking out 0.7.2, you can revert the database migrations included in 0.7.3:

./bw-dev migrate bookwyrm 0192_sitesettings_user_exports_enabled

Is that ok with a dockerless install?

Minnozz commented 5 months ago

Is that ok with a dockerless install?

For a dockerless install, you would need the following command:

venv/bin/python3 manage.py migrate bookwyrm 0192_sitesettings_user_exports_enabled
marcusyoung commented 5 months ago

Is that ok with a dockerless install?

For a dockerless install, you would need the following command:

venv/bin/python3 manage.py migrate bookwyrm 0192_sitesettings_user_exports_enabled

Tried this, and although it appeared to revert database changes, when I tried to bring Bookwyrm back up it failed. Journalctl showed errors about missing columns etc. So have had to go back to 0.7.3.

marcusyoung commented 5 months ago

More information. The problem seems to be specifically related to creating or importing (from search) books that have a cover image. If that can help anyone narrow things down?

marcusyoung commented 5 months ago

What information can I provide to expediate a fix for this?

Minnozz commented 5 months ago

This was discussed further on Matrix; most likely this is the same issue as https://github.com/bookwyrm-social/bookwyrm/pull/3342

@marcusyoung will try to manually apply that fix and report back if it works.

maxheadroom commented 5 months ago

I have the same issue. I've manually reverted the DB migrations from 0.7.3 but still run into the issue that searching for stuff results in a Server Error if the search content can't be found locally.. Which Matrix room are you using?

When searching remote libraries/catalogs the server returns an error after ~ 15 seconds. I can see that it's contacting other instances in the Background. But the Frontend seems to have a timeout of 15 seconds. I believe this is related to the import issue discussed here.

Minnozz commented 5 months ago

I have the same issue. I've manually reverted the DB migrations from 0.7.3 but still run into the issue that searching for stuff results in a Server Error if the search content can't be found locally.. Which Matrix room are you using?

The Matrix room is https://matrix.to/#/%23bookwyrm%3Amatrix.org

When searching remote libraries/catalogs the server returns an error after ~ 15 seconds. I can see that it's contacting other instances in the Background. But the Frontend seems to have a timeout of 15 seconds. I believe this is related to the import issue discussed here.

If your issue is the same as the one discussed here, and you also run a setup without Docker, you can try removing and recreating the Python venv as a workaround

marcusyoung commented 5 months ago

This was discussed further on Matrix; most likely this is the same issue as #3342

@marcusyoung will try to manually apply that fix and report back if it works.

I have made the change to requirements.txt and installed the new requirement. This appears to have fixed the problem. I'll await user feedback to be sure. I didn't do a new .venv at this time, as I need to prepare for that and to be sure there won't be any issues installing Python 3.11 (which isn't officially supported on jammy).