internetarchive / openlibrary

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

Save_many fails for specific set of work IDs #4832

Open seabelis opened 3 years ago

seabelis commented 3 years ago

When using colab to migrate these work editions OL15037366W,OL15037371W,OL16056627W into OL73087W an error is thrown.

Evidence / Screenshot (if possible)

Relevant url?

https://colab.research.google.com/drive/1OdyL5nPf4PEaWavuxCDYs9q2C4JKrP90#scrollTo=oODoBD3kHk6v&line=1&uniqifier=1

Steps to Reproduce

  1. Go to ... https://colab.research.google.com/drive/1OdyL5nPf4PEaWavuxCDYs9q2C4JKrP90#scrollTo=oODoBD3kHk6v&line=1&uniqifier=1
  2. Do save_set = [] for work in works: editions = work.editions for ed in editions: ed.work_olid = into_olid save_set.append(ed) response = ol.save_many(save_set, 'moving edition(s) to primary work') print('save_set:',save_set) response.raise_for_status() response

/usr/local/lib/python3.7/dist-packages/requests/models.py in raise_for_status(self) 941 942 if http_error_msg: --> 943 raise HTTPError(http_error_msg, response=self) 944 945 def close(self):

HTTPError: 400 Client Error: Bad Request for url: https://openlibrary.org/api/save_many

Details

Proposal & Constraints

The script works for other sets of Works. Just this set throws the error.

Related files

Stakeholders

@cdrini

scottbarnes commented 2 months ago

Here's the POST that fails:

400 POST /openlibrary.org/save_many {'comment': 'moving edition(s) to primary work', 'query': '[{"notes": {"type": "/type/text", "value": "Clifford"}, "identifiers": {"goodreads": ["858721"], "librarything": ["54614"]}, "title": "Clifford the Big Red Dog (Clifford the Big Red Dog)", "publish_date": "September 1, 1997", "publishers": ["Cartwheel"], "ia_box_id": ["IA114211"], "weight": "8 ounces", "first_sentence": "My dog is a big red dog.", "covers": [383474], "physical_format": "Board book", "languages": [{"key": "/languages/eng"}], 
"source_records": ["ia:cliffordbigreddo00brid", "bwb:9780590341257"], "edition_name": "Brdbk edition", "subjects": ["Fiction", "Picture books", "Dogs", "Children\'s Books/Baby-Preschool", "Juvenile Fiction", "Children: Kindergarten", "Animals - Dogs", "Animals - Pets", "Classics", "Children\'s Baby - Boardbooks"], "type": {"key": "/type/edition"}, "physical_dimensions": "4.7 x 5 x 0.6 inches", "ocaid": "cliffordbigreddo00brid", "isbn_10": ["0590341251"], "isbn_13": ["9780590341257"], "latest_revision": 2, "revision": 2, "created": {"type": "/type/datetime", "value": "2024-07-15T17:01:25.685919"}, "last_modified": {"type": "/type/datetime", "value": "2024-07-15T17:02:06.191774"}, "key": "/books/OL7886371M", "number_of_pages": 32, "works": [{"key": "/works/OL73087W"}]}, {"notes": {"type": "/type/text", "value": "Read with Clifford. BLah."}, "identifiers": {"librarything": ["54614"], "goodreads": ["263722"]}, "title": "Clifford The Big Red Dog", "publish_date": "May 1, 2005", "publishers": ["Cartwheel"], "covers": [279166], "languages": [{"key": "/languages/eng"}], "source_records": ["ia:cliffordbigreddo00norm_2", "promise:bwb_daily_pallets_2022-03-25", "bwb:9780439734318", "promise:bwb_daily_pallets_2021-05-06"], "type": {"key": "/type/edition"}, "first_sentence": "I\'m Emily Elizabeth, and I have a dog.", "local_id": ["urn:bwbsku:W7-BPQ-970", "urn:bwbsku:O6-DFL-406"], "ocaid": "cliffordbigreddo00norm_2", "isbn_10": ["0439734312"], "isbn_13": ["9780439734318"], "oclc_numbers": ["59672390"], "latest_revision": 2, "revision": 2, "created": {"type": "/type/datetime", "value": "2024-07-15T17:01:25.685919"}, "last_modified": {"type": "/type/datetime", "value": "2024-07-15T17:02:38.473147"}, "key": "/books/OL7515149M", "number_of_pages": 40, "works": [{"key": "/works/OL73087W"}]}, {"description": {"type": "/type/text", "value": "Blah."}, "title": "Clifford the Big Red Dog (Clifford the Big Red Dog)", "publish_date": "1963", "publishers": ["Scholastic Book Services"], "ia_box_id": ["IA112718"], "covers": [6986622], "ia_loaded_id": ["cliffordbigreddo1963brid"], "publish_places": ["New York"], "pagination": "[46] p. :", "source_records": ["ia:cliffordbigreddo1963brid", "amazon:0590080288", "bwb:9780590080286"], "full_title": "Clifford the big red dog", "languages": [{"key": "/languages/eng"}], "subjects": ["Dogs", "Fiction"], "publish_country": "nyu", "by_statement": "story and pictures by Norman Bridwell", "type": {"key": "/type/edition"}, "ocaid": "cliffordbigreddo1963brid", "isbn_10": ["0590080288"], "isbn_13": ["9780590080286"], "lccn": ["00008013"], "oclc_numbers": ["423791840"], "lc_classifications": ["PZ4.9.B7496 Cf 1963"], "latest_revision": 2, "revision": 2, "created": {"type": "/type/datetime", "value": "2024-07-15T17:01:25.685919"}, "last_modified": {"type": "/type/datetime", "value": "2024-07-15T17:02:59.399784"}, "key": "/books/OL24956080M", "number_of_pages": 46, "works": [{"key": "/works/OL73087W"}]}]'}

Maybe something in there violates the Edition schema?