openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Edition's bookcover alt-text should pull author from work

Open LeadSongDog opened this issue 8 years ago • 26 comments

Correcting a work's author (e.g. https://openlibrary.org/works/OL3531880W/Living_with_Leviathan?b=4&a=3&_compare=Compare&m=diff ) also corrects the Alt-text for the work cover, (e.g. to alt="Cover of: Living with Leviathan by David Brian Smith" ) but fails to correct the Alt-text for the editions below it, instead leaving it untouched (e.g. as alt="Cover of: Living with Leviathan by David Buchanan Smith" ). Might this be why the edition is still found on searches for the old author spelling?

view-source:https://openlibrary.org/books/OL17631357M/Living_with_Leviathan shows the error at lines 349, 357, 371

Proposed fix: Ensure the edition alt-text author name uses the same source data as the rest of the edition interface, which takes the author attached to the work(if it exists)

LeadSongDog avatar Apr 28 '17 20:04 LeadSongDog

Further, the edition edit-->add cover-->manage leads to a 500: https://openlibrary.org/books/OL17631357M/Living_with_Leviathan/edit#imagesManage

LeadSongDog avatar Apr 30 '17 14:04 LeadSongDog

Still there: leviathan The old author, OL592017A, also shows in the edition's json display: https://openlibrary.org/books/OL17631357M.json still includes "authors": [{"key": "/authors/OL592017A"}] though it should have changed to "/authors/OL1862019A" with that edit last April 28.

LeadSongDog avatar Mar 12 '18 16:03 LeadSongDog

@mekarpeles @hornc At: https://openlibrary.org/works/OL9340281W/Advanced_Organic_Chemistry?b=2&a=1&_compare=Compare&m=diff I changed the Work record to link to the correct Author record. This should have fixed all the Edition records and Covers under that Work, but clearly it did not: authorbug

LeadSongDog avatar Mar 29 '18 16:03 LeadSongDog

This sounds like the same thing which has been reported multiple times before.

What is new about this case?

tfmorris avatar Mar 30 '18 04:03 tfmorris

Just trying to give an example that is clear enough to get some attention. After almost a year, I don't Think that this has even been diagnosed yet, so I wanted to provide a very clear example.

LeadSongDog avatar Mar 30 '18 07:03 LeadSongDog

This appears to be unresolved. @hornc I'm guessing this is your purview. Are you willing to be assignee? Note, being the assignee doesn't necessarily mean you are responsible for doing the work, just responsible for gathering/providing information to address the issue. From the Wiki.

The assigned owner is not necessarily the person who will fix the issue (it is not necessarily even established, at that point, if or when the issue will be fixed at all), but rather they are the person who will do as much or as little as needed to handle the issue (asking questions, soliciting input, establishing and updating the priority, checking if it is a duplicate, etc).

Once an issue is labeled State: Work In Progress, the owner is the individual doing the work, or leading/coordinating the group that is doing the work.

I've added labels per context: let me know your thoughts

xayhewalo avatar Oct 27 '19 23:10 xayhewalo

Some of the other issues which cover this are #628 and #891

tfmorris avatar Oct 28 '19 17:10 tfmorris

Something weird is going on here; the edition still has the wrong author (...017A instead of ...019A) in the JSON. I don't think this is a solr issue. The work and edition author fields are out of sync (for some reason).

https://openlibrary.org/books/OL17631357M.json

cdrini avatar Nov 11 '19 19:11 cdrini

I'm labeling this as an Infogami issue, but I'm guessing it may have something to do with Memcache as well. @tfmorris @cdrini @hornc What are your thoughts?

xayhewalo avatar Nov 12 '19 17:11 xayhewalo

My guess would be this is not a memcache issue (the .json endpoints don't use memcache). Not sure what the root cause is that could have caused the work/edition to fall out of sync :/

Ok, comparing with https://openlibrary.org/books/OL25934687M.json , it looks like authors should not be on the edition record at all. My guess would be it appeared as a result of some fluke error. (This also used to be an orphan, so I'd guess there might've been some issue with un-orphaning it). I can fix this specific edition manually, and create an issue to investigate further.

cdrini avatar Nov 12 '19 17:11 cdrini

Fixed this specific edition https://openlibrary.org/books/OL17631357M/Living_with_Leviathan

cdrini avatar Nov 12 '19 17:11 cdrini

New issue: https://github.com/internetarchive/openlibrary/issues/2625

cdrini avatar Nov 12 '19 17:11 cdrini

@cdrini I don't think this should be closed - as I see it, the fix for this issue is for edition covers to pull the author name from the work like every other piece of UI code, for display consistency.

#2625 is more than this.

hornc avatar Nov 12 '19 18:11 hornc

:+1: Fair enough; would you mind re-opening and updating the description?

cdrini avatar Nov 12 '19 18:11 cdrini

Assigning jdlrobson (not tagging per request) per slack discussion since it seems like something he word do.

xayhewalo avatar Nov 12 '19 19:11 xayhewalo

I'm not understanding the issue here or the high priority. When I visit the URL https://openlibrary.org/books/OL17631357M/Living_with_Leviathan the image of the cover has the alt text "Cover of: Living with Leviathan | David B Smith".

What else is needed?

jdlrobson avatar Dec 06 '19 22:12 jdlrobson

@jdlrobson, that's because @cdrini fixed that specific edition last month, but my example of OL10328206M still has the same problem. {"publishers": ["John Wiley & Sons Inc"], "languages": [{"key": "/languages/eng"}], "classifications": {}, "key": "/books/OL10328206M", "title": "Advanced organic chemistry", "identifiers": {"goodreads": ["1580424"]}, "isbn_13": ["9780471514664"], "created": {"type": "/type/datetime", "value": "2008-04-30T09:38:13.731961"}, "physical_format": "Hardcover", "isbn_10": ["0471514667"], "latest_revision": 5, "last_modified": {"type": "/type/datetime", "value": "2018-03-29T15:08:46.741342"}, "authors": [{"key": "/authors/OL3385469A"}], "works": [{"key": "/works/OL9340281W"}], "type": {"key": "/type/edition"}, "subjects": ["Chemistry"], "revision": 5}

Please note that it still shows the old author key OL3385469A, not the work author OL401050A which renders as:

staleauthor

The UI gives no way to correct the author entry in the edition record, just in the work record.

LeadSongDog avatar Dec 11 '19 15:12 LeadSongDog

So this seems like a backend problem not UI problem.

The template https://github.com/internetarchive/openlibrary/blob/a485ea50abfb66697a303356f4810a364bb4b8c0/openlibrary/templates/covers/book_cover.html

is pretty dumb.. all it does is outputs the value of book.get_authors

So the issue lies somewhere outside the UI (wherever that get_authors function is defined). Fix that and you'll fix the UI.

jdlrobson avatar Dec 12 '19 01:12 jdlrobson

@jdlrobson It seems there are multiple places where get_authors is defined, perhaps that is a problem in itself?:

https://github.com/internetarchive/openlibrary/blob/0aadc9d596671e48248cc6bcc2ba82020c0f0f4a/openlibrary/core/lists/engine.py#L38

https://github.com/internetarchive/openlibrary/blob/19f2062f519ff3189d36ce23d252f1f5a2d36c92/openlibrary/plugins/books/dynlinks.py#L164

https://github.com/internetarchive/openlibrary/blob/19f2062f519ff3189d36ce23d252f1f5a2d36c92/openlibrary/plugins/books/dynlinks.py#L337

https://github.com/internetarchive/openlibrary/blob/51d7b5bf04959d23c4c216519fa9a13b34285866/openlibrary/plugins/upstream/models.py#L59

https://github.com/internetarchive/openlibrary/blob/51d7b5bf04959d23c4c216519fa9a13b34285866/openlibrary/plugins/upstream/models.py#L596

https://github.com/internetarchive/openlibrary/blob/c05b856c688658fd4ffa50e3aa1040936c51c2c0/openlibrary/plugins/openlibrary/home.py#L235

LeadSongDog avatar Jan 23 '20 16:01 LeadSongDog

If no one is currently working on this issue I'd love to give it a try. I do have a few clarifying questions to make sure I'm understanding the problem corrently.

  1. Is there a good current example of the OP's issue? Since this thread is over 5 years old, having a current example would be nice for testing and finding the true cause of the bug.
  2. From what I've read in #2625 and this post, the issue seems to stem from how authors are stored. There is main author of the work which can be edited and updates correctly but there can also be specific authors for each edition to account for other roles (i.e. translator, narrator, etc.). What I'm confused about is how exactly the data is stored in the .json files and.
  3. @LeadSongDog mentioned that get_authors() is defined in multiple places and maybe the issue is from that. The only function signatures that match the call used in book_cover.html are the ones in model.py defined in the Edition and Work class respecitvly. https://github.com/internetarchive/openlibrary/blob/ba05bb35a9b8b21234498993512c5ac8b5a3d868/openlibrary/templates/covers/book_cover.html#L1-L8 https://github.com/internetarchive/openlibrary/blob/ba05bb35a9b8b21234498993512c5ac8b5a3d868/openlibrary/plugins/upstream/models.py#L61-L66 https://github.com/internetarchive/openlibrary/blob/ba05bb35a9b8b21234498993512c5ac8b5a3d868/openlibrary/plugins/upstream/models.py#L629-L633 My question is how are these two classes used by the system and how do they interact with the data stored in the .json files?

Beyond those three questions, my guess is that the wrong get_author() is being called in book_cover.html, resulting in out of sync author names to be displayed on the bookcover I'm not sure how to test this theory so any and all guidance would be appreciated.

UndVasIstDas avatar Aug 06 '25 22:08 UndVasIstDas

Hi @UndVasIstDas -- will wait for @cdrini to followup on this issue and will assign you in the meantime. Thank you for your interest and for investigating + asking questions!

It seems to be at first glance that there may be several issues open all broadly related to the same core issue, that solr is not performing an update across all works / editions when an author is edited; @cdrini to confirm this is the root cause of this issue. If so, this may not be something one can easily fix by e.g. swapping out a function call.

@cdrini to opine

mekarpeles avatar Aug 07 '25 19:08 mekarpeles

You've correctly identified the cover is rendered by https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/type/edition/view.html#L210

The cover itself is rendered by the databarWork macro: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/macros/databarWork.html#L22

And then the covers/book_cover template: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/covers/book_cover.html#L4-L8

@cdrini can correct me, but it's possible either the author_names from book.get_authors() or book.get('by_statement','') are not populating correctly across work / edition.

The first get_authors you mention is part of the Edition: https://github.com/internetarchive/openlibrary/blob/ba05bb35a9b8b21234498993512c5ac8b5a3d868/openlibrary/plugins/upstream/models.py#L47-L66

The second one is from the Work: https://github.com/internetarchive/openlibrary/blob/ba05bb35a9b8b21234498993512c5ac8b5a3d868/openlibrary/plugins/upstream/models.py#L557-L633

The Edition seems to be more complete and appears to give both work_authors + authors. One question is which we have in the cover (given we're showing the cover of the edition, I presume that's what we have in the cover template).

I'd start by looking at where/how the title and author section is rendered here: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/type/edition/view.html#L208

Which seems to be that it's agnostic... https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/type/edition/title_and_author.html#L36-L37

mekarpeles avatar Aug 12 '25 23:08 mekarpeles

Thanks @mekarpeles !

@UndVasIstDas yep, your reading is completely correct. I did a pass through the code to see everywhere .get_authors is used and it seems to be only used for rendering, and not for e.g. merging/data maintenance. So I think we should update the Edition.get_authors implementation to not combine the two authors. E.g.

def get_authors(self) -> list[Author]:
    if self.works:
        return self.works[0].get_authors()
    else:
        authors = [follow_redirect(a) for a in self.authors]
        return [a for a in authors if a and a.type.key == "/type/author"]

That'll let the template that is currently calling get_authors() on the edition record get the actual authors we expect. We don't really expect authors on the edition in this way; there's more discussion around it here: #2625 . But in most cases, this one here included, we only really care about the work authors, unless the edition doesn't have a work.

Let me know if you have any questions!

cdrini avatar Aug 13 '25 10:08 cdrini

And here's a modern record that exhibits the issue ; you can see the incorrect and duplicate authors on the left https://openlibrary.org/books/OL4968844M/La_science_des_re%CC%82ves .

Image

cdrini avatar Aug 13 '25 10:08 cdrini

@UndVasIstDas Hi, have you made any progress on this ticket? I was taking a look at this but am having so difficulty in reproducing the error. I edited the authors of multiple books (added author, removed author, replaced author) but the alt text in for the covers of the editions don't show the author... Only the book title is shown. I'd greatly appreciate any help!

gabenotgave avatar Dec 02 '25 04:12 gabenotgave

And here's a modern record that exhibits the issue ; you can see the incorrect and duplicate authors on the left https://openlibrary.org/books/OL4968844M/La_science_des_re%CC%82ves .

Image

Thanks @cdrini, that is a very clear example: it shows the same author (OL108452A) twice, likely because (examining the json) the edition record has a redundant link to the author record. Is the cover pulling from both the work author record and the edition author record despite them being the same? Is it as simple as testing for equality, or does the old issue of inaccessible and obscured edition authors still need attention?

LeadSongDog avatar Dec 02 '25 14:12 LeadSongDog