internetarchive / openlibrary

One webpage for every book ever published!
https://openlibrary.org
GNU Affero General Public License v3.0
5.09k stars 1.33k forks source link

Error: expected /type/author, found /type/redirect #1445

Open seabelis opened 5 years ago

seabelis commented 5 years ago

To see error message:

  1. Edit this work: https://openlibrary.org/works/OL14917323W/Romeo_and_Juliet_Tempest (When I do so and save, I am returned to the edit form with no error message.) Edits not saved. (captured in #1566)
  2. Go to filtered list of works https://openlibrary.org/search?q=title%3Aromeo+author%3Ashakespeare&mode=everything&page=1 (already open in my case)
  3. Refresh page and see "expected /type/author, found /type/redirect"
hornc commented 5 years ago

Very interesting, sounds like there are two things going on here

2 & 3 sounds like we have a problem where error alerts are appearing on different pages?? I think I have seen something similar recently where error alerts at the top of the page have stacked up and appeared delayed. It sounds like you were seeing errors from an action in a different tab! @jdlrobson do you have any insight into this? I think error status messages are being displayed late, i.e. not immediately on the page after the error has occurred.

For the original error 1, the edition https://openlibrary.org/books/OL10391732M.json has an old author /authors/OL2622133A (now a redirect) in the data. Editions with redirects should still be editable, we should fix this problem. Alternatively we should just strip authors which are redirects from editions, since authors are as standard stored at the work level.

LeadSongDog commented 5 years ago

The wikimedia approach to redirects is simple and works well. When an url is redirected, a hatnote tells the reader "Redirected from ", where is hyperlinked to the original url with "&redirect=no" suffixed.

See for example the spelling error: https://en.wikipedia.org/w/index.php?title=Volcanoe

LeadSongDog commented 5 years ago

@seabelis @hornc I saw this again last night when I attempted to add author C. T. Onions to OL16290844W (though technically he was an editor). The add author dropdown showed a match for OL18344A in solr cache (as seen at https://openlibrary.org/search/authors?q=C.+T.+Onions&mode=everything), when it should have shown the redirection target https://openlibrary.org/authors/OL1692246A/Charles_Talbut_Onions instead. I don't think it is necessary to fix the solr cache in order to solve this, just check if the selected entry on the dropdown is a redirect and act accordingly if it is.

LeadSongDog commented 5 years ago

https://github.com/internetarchive/openlibrary-client/issues/78 relates

seabelis commented 5 years ago

Thanks for the information. I'm not sure how I would check for this though. If I activate the author dropdown for the work it shows the main profile for William Shakespeare. I've also tried using OL9388A with same result. I guess what I'm saying is I'm not sure how to act accordingly; what would that action be?

LeadSongDog commented 5 years ago

To reproduce, edit the work. Click the add author checkbox. Type in C. T. Onions. In a second or less the yellow suggestion drop down for that name appears. Click on that name. Hit save. If the diagnostic does not show promptly it may need a browser refresh. Diagnostic or not, the author will not be added to the work. What should happen instead is that the target author is added rather than the redirect.

[update: the C. T. Onions entry is no longer appearing in the dropdown, perhaps the cache was flushed? It now shows Charles Talbut Onions, the target of the redirect.]

seabelis commented 5 years ago

I cannot reproduce on OL10391732M. If I select the author and save I just land back on the edit form and nothing is saved. I've also tried selecting an incorrect author just to see if the author profile was the issue, but same result.

seabelis commented 5 years ago

Here's another one. I don't think it's the author profile as I can edit the other editions of the same work. https://openlibrary.org/books/OL22134859M/Dolores_Claiborne

tfmorris commented 5 years ago

The error message pane not working is also reported in #1566, so let's focus this ticket on the redirect error itself.

In the most recent, Dolores Claiborne, example, I was able to reproduce the behavior when both adding Stephen King as a new author and replacing the existing author. The author record is /authors/OL2162284A but neither that, the work, not the edition appear to be redirects as far as I can tell, so I'm not sure what it's complaining about (improvement to error message - mention that actual URL you're complaining about as a redirect to ease troubleshooting)

tfmorris commented 5 years ago

So the redirect is the author that's in the original edition record https://openlibrary.org/books/OL22134859M.json which points to http://openlibrary.org/authors/OL19981A.json, but I can't figure out how to get rid of it. All the editing seems to be operating on the works author, not the edition author.

seabelis commented 5 years ago

I think there is other inaccessible data on those edition records as well. I've seen first sentences associated with editions only and no way to access.

seabelis commented 5 years ago

Another one. https://openlibrary.org/books/OL13519675M/Shakespeare's_tragedy_of_Hamlet

seabelis commented 5 years ago

Another one. https://openlibrary.org/books/OL9143428M/Hamlet_Hamlet

LeadSongDog commented 5 years ago

Hmm. Some history diving finds https://openlibrary.org/works/OL362709W/Hamlet?b=12&a=10&_compare=Compare&m=diff

The move to canonical form has really obscured these things.

tfmorris commented 5 years ago

I don't see any problem with https://openlibrary.org/books/OL13519675M (unless someone fixed it already), but https://openlibrary.org/books/OL9143428M.json has an author record of https://openlibrary.org/authors/OL2622133A.json which is a redirect. In other words, the same analysis as my Nov. 15 analysis. They're not fixable with the current UI because the editions' authors aren't visible.

@LeadSongDog That's the work. The problem is with the edition.

seabelis commented 5 years ago

Yes, OL13519675M seems okay now.

seabelis commented 5 years ago

More... https://openlibrary.org/works/OL14915729W/The_enfolded_Hamlets https://openlibrary.org/works/OL14916309W/La_tragedie_d'hamlet https://openlibrary.org/works/OL14915889W/Hamlet_The_Tragicall_Historie_of_Hamlet_Prince_of_Denmarke_1602_-_Richard_II_The_Tragedie_of_King_Ri https://openlibrary.org/works/OL14918003W/The_Tragicall_History_of_Hamlet_Quarto_2 https://openlibrary.org/works/OL14916310W/La_Tragique_histoire_d'Hamlet https://openlibrary.org/works/OL14915790W/The_Hamlet_3x2_Text_Research_Toolset https://openlibrary.org/works/OL14916446W/Macbeth_-_Hamlet https://openlibrary.org/works/OL14915604W/Compact_Bedford_Introduction_to_Literature_6e_and_Hamlet

seabelis commented 5 years ago

The issue with the error messages has been resolved, but the issue making edits to the works above still exists.

hornc commented 4 years ago

@seabelis I think all the Shakespeare, Stephen King, and work editing issues should be resolved now --

seabelis commented 4 years ago

Confirmed. These two are still uncooperative, https://openlibrary.org/books/OL19624190M/The_tales_of_Tchehov, https://openlibrary.org/books/OL13427904M/Memoria_Delle_Mie_Puttane_Tristi

xayhewalo commented 4 years ago

@hornc Is there a systematic solution to this issue in progress?

LeadSongDog commented 4 years ago

@seabelis Those two both have the same problem: the editions' json each contain a link to an author record (OL19677A and OL2629754A respectively). Both records are redirects. The real solution is to remove the author link from the edition.

tfmorris commented 4 years ago

2552 would be one solution to the systemic problem. Removing authors from editions would be another, more permanent solution.