openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

"Unknown Author" causes page error

Open JeffKaplan opened this issue 6 years ago • 8 comments

unknown author causes error: https://openlibrary.org/books/OL18689372M/Tangled_roots https://openlibrary.org/books/OL8559610M/Tangled_roots /opt/openlibrary/deploys/openlibrary/68474f6/openlibrary/templates/type/edition/view.html: error in processing template: IndexError: list index out of range (falling back to default template)

JeffKaplan avatar Oct 12 '20 18:10 JeffKaplan

Note it looks like this bug is for the absence of an authors attribute. There is an author name "unknown" that can properly render it's book page: https://openlibrary.org/books/OL27688877M

xayhewalo avatar Oct 13 '20 01:10 xayhewalo

@guyjeangilles we can solve this issue by initializing the author name to be "The author is unknown", This will also resolve the issue and the data will be filled by the string itself Can I work on this

ArunTeltia avatar Oct 15 '20 03:10 ArunTeltia

@ArunTeltia feel free to make a pull request

xayhewalo avatar Oct 15 '20 14:10 xayhewalo

@guyjeangilles I try to find the Author model but I am getting some problems like where to find it, can you help me in locating the file

ArunTeltia avatar Oct 16 '20 07:10 ArunTeltia

I wanted to test various code fixes related to this but to be able to do that I'd need to replicate the missing author attribute. This doesn't appear possible unless adding data via bot or manually editing an entry in the db. Easiest path for me seemed to manually edit my local db but I found that I was not able to elevate to the postgres user within the docker container.

openlibrary@70fc6da8b507:/openlibrary$ su postgres Password: su: Authentication failure

as described in https://github.com/internetarchive/openlibrary/wiki/Getting-Started#database

Anyone have this password or have a better way for me to replicate the bug?

perryjr avatar Nov 01 '20 20:11 perryjr

@perryjr You can import production data into your local dev environment using the instructions here. I've confirmed that importing /books/OL18689372M lets you reproduce the issue locally. You can then add ?debug=true to the URL to get a stacktrace.

In the future, if you find that you need to make changes to the database (I almost never have, for what it's worth), you need to make sure you are in the db container, not the web container:

$ docker-compose exec db bash
root@747df934f13a:/# whoami
root
root@747df934f13a:/# su postgres
postgres@747df934f13a:/$ whoami
postgres

Also, it doesn't look to me like the problem is the missing authors field (though that might cause problems later too). It looks like it's also missing a "works" field: image

You can confirm the missing field in https://openlibrary.org/books/OL18689372M.json. You can compare this with a well-formed book here: https://openlibrary.org/books/OL25393828M.json

SouthGoingZax avatar Nov 24 '20 03:11 SouthGoingZax

@SouthGoingZax I don't know how I missed that wiki area, thank you. Your assistance is extremely helpful while I get more comfortable with the architecture and codebase. Trying to access the db while inside the web container ... HAH! Thanks again!

perryjr avatar Nov 24 '20 13:11 perryjr

No problem =) However, it looks like this is fixed by #4052 (the fix is on the dev server, which you can confirm by going to https://dev.openlibrary.org/books/OL18689372M/Tangled_roots). This issue also looks like a dupe of #4051, so I'll go ahead and close this issue.

SouthGoingZax avatar Nov 24 '20 21:11 SouthGoingZax