internetarchive / internetarchive/openlibrary-client

Create new book fails: "Creation failed, book may already exist!"

Open
#186 10 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
506
Forks
110
PR merge metrics
No merged PRs in 30d

Description

Creating a new book fails. As an example, take this guide book for rock climbing. The book exist on amazon,
https://www.amazon.it/Schweiz-Plaisir-sch%C3%B6nsten-Klettereien-Niveau-4a-6a/dp/3906087034

```
ol --create '{"identifiers": {"isbn_10": ["3906087034"]},
"title": "Schweiz Plaisir",
"publisher": "Filidor, Schweiz",
"publish_date": "1993",
"pages": "256",
"author": "Jürg Von Känel"
}'
```
returns
```
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/bibliotek/bin/ol", line 8, in
sys.exit(main())
File "/usr/local/anaconda3/envs/bibliotek/lib/python3.8/site-packages/olclient/cli.py", line 129, in main
edition = ol.Work.create(book)
File "/usr/local/anaconda3/envs/bibliotek/lib/python3.8/site-packages/olclient/openlibrary.py", line 235, in create
ed = cls.OL.create_book(book, debug=debug)
File "/usr/local/anaconda3/envs/bibliotek/lib/python3.8/site-packages/olclient/openlibrary.py", line 935, in create_book
return self._create_book(
File "/usr/local/anaconda3/envs/bibliotek/lib/python3.8/site-packages/olclient/openlibrary.py", line 983, in _create_book
raise ValueError('Creation failed, book may already exist!')
ValueError: Creation failed, book may already exist!
```
Looking at https://openlibrary.org/api/books?bibkeys=ISBN:3906087034&jscmd=data&format=json, we see the book does not exist. Same for google books,
https://www.googleapis.com/books/v1/volumes?q=isbn:3906087034&fields=items/volumeInfo(title,subtitle,authors,publisher,publishedDate,language,industryIdentifiers,pageCount,imageLinks.thumbnail,categories)&maxResults=1

I am using the latest git version. But I get same response using the version from pip.

Am I doing something wrong?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the `ol --create` command and ISBN shown in the issue. Start in `olclient/openlibrary.py`, especially `create_book` and `_create_book`, and trace why the creation response reaches the `ValueError` at line 983. Done means this valid, previously absent book can be created without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.