internetarchive / openlibrary

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

API should reject edits with no changes #1903

Open tfmorris opened 5 years ago

tfmorris commented 5 years ago

Description

Due to a front end bug, the backend was given an "edit" request which didn't actually change anything. The backend API should reject any requests which result in no changes.

Evidence

https://dev.openlibrary.org/books/OL23271756M/Soul_made_flesh?b=10&a=9&_compare=Compare&m=diff

Details

In this particular case, there were two corresponding edits which consisted solely of bumping the version number for the related entity, neither of which had any actual changes.

https://dev.openlibrary.org/books/OL23271756M.json?m=history https://dev.openlibrary.org/works/OL13699253W.json?m=history

hornc commented 5 years ago

Hmm, the edit also added an empty classifications: { } field to the JSON. It's there in v10, but not in v9.

I thought no-op saves were already discarded, but clearly there are at least some situations where this is not the case. I'll confirm whether the API saves are smart enough to discard completely identical saves, and then follow up on where the classifications: { } came from.