internetarchive / internetarchive/openlibrary

Save_many fails for specific set of work IDs

Open
#4,832 1 comment 0 reactions 0 assignees View on GitHub
Affects: Librarians Lead: @scottbarnes Priority: 3 Type: Bug
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 19h
Merged PRs (30d)
138

Description

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`

* Actual:
```
HTTPError Traceback (most recent call last)
in ()
7 response = ol.save_many(save_set, 'moving edition(s) to primary work')
8 print('save_set:',save_set)
----> 9 response.raise_for_status()
10 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
* Expected:

### Details

- **Logged in (Y/N)?**
- **Browser type/version?**
- **Operating system?**
- **Environment (prod/dev/local)?** prod

### Proposal & Constraints

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

### Stakeholders

@cdrini

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.