Openlibrary: Identifiers are sometimes lost on save

Created on 3 Apr 2019  路  12Comments  路  Source: internetarchive/openlibrary

Description

I have noticed that identifiers I've added are sometimes lost after saving an edited record.

  1. copydocs.py /books/OL23278082M?v=18 -r
  2. Edit the book as follows:
    a. Add google: fo4rzdaHDAwC
    b. Remove goodreads
    c. Add goodreads: 44415839
  3. Save

Relevant url?
https://openlibrary.org/books/OL23278082M/Harry_Potter_and_the_Sorcerer's_Stone?b=19&a=18&_compare=Compare&m=diff

Expectation

  • Expected: google id set.
  • Actual: google not set.

No identifiers should be lost once added.

Details
This does not happen all the time and it does not affect all identifiers added at a given time. I will frequently search by highlighting and right clicking an ISBN after adding it while still in edit mode, so I know it's not just a matter of me neglecting to hit the ADD button. I've also noticed a lot of Goodreads IDs are missing that I'm sure I'd added.

  • Logged in (Y/N)? Y
  • Browser type/version? Chrome Version 73.0.3683.86 (Official Build) (64-bit)
  • Operating system? Win 7 Pro
1 Editing Bug

All 12 comments

Caught one! https://openlibrary.org/books/OL23278082M/Harry_Potter_and_the_Sorcerer's_Stone?b=19&a=18&_compare=Compare&m=diff
In this case I'd removed an incorrect ISBN10 and added the correct ISBNs 10/13. After save, neither ISBN was present.

@jdlrobson or @cdrini I'm hearing from @hornc that this seems to happen on the front-end and isn't a backend-issue. If you have any context on this issue (what fix we should pursue) please do post

@hornc do you know what's missing in the request?
Any clear replication steps I can try out locally?

@seabelis What were the correct ISBNs you were trying to add?

Ah, never mind; I see you were able to add them in a future edit.

Ok, I think the issue is with the [x] buttons. I think they sometimes delete the wrong identifier. So this is an issue when you remove/add identifiers in the same edit :/

To reproduce (I basically did snippets of Lisa's edits until I found what steps reproduced the issue).

  1. copydocs.py /books/OL23278082M?v=18 -r
  2. Edit the book as follows:
    a. Add google: fo4rzdaHDAwC
    b. Remove goodreads
    c. Add goodreads: 44415839
  3. Save

Expected: google id set.
Actual: google not set.

Actually, it doesn't look like it's the [x] buttons; it looks like the identifier--$index values are wrong (this is after step 2 of repro):
image

This onRemove method should probably be updating the identifier indices:
https://github.com/internetarchive/openlibrary/blob/b7fefd63db2b73fdc66c902be6d5c5fb990fb0cd/openlibrary/plugins/openlibrary/js/jquery.repeat.js#L86-L90

Cause index is just set to the number of trs in the table:
https://github.com/internetarchive/openlibrary/blob/b7fefd63db2b73fdc66c902be6d5c5fb990fb0cd/openlibrary/plugins/openlibrary/js/jquery.repeat.js#L65

This seems like it would be down your alley, @jdlrobson ; feel free to assign to yourself if you want to take it on.

Thanks for the debug steps!

Thanks @cdrini, I had a feeling it was something like this but wasn't able to task switch sufficiently to get into the js and follow it through all the way! Really appreciate your debugging skills on this! :)

I've made some progress on this and have a minimum test case. Just need to fix it now. Stepping out now but hope to have it by end of day.

Was this page helpful?
0 / 5 - 0 ratings