internetarchive / internetarchive/openlibrary

Edit Diffs fail to note changes to Links on Works

Open
#3,414 0 comments 0 reactions 0 assignees View on GitHub
Affects: Librarians Affects: UI Lead: @mekarpeles Needs: Investigation Priority: 3 Type: Bug
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 19h
Merged PRs (30d)
138

Description

Changes to the URL or anchor text of links on works are not detected by the diff algorithm. As a result, the diff view is sometimes just empty, or displays the erroneous (and grammatically slightly off) message "Both the revisions are identical.".

Steps to reproduce:

1. Edit some version with existing external links
2. change a link's URL and text
3. save and view the diff for this change

* Actual: The diff view is either empty or says "Both the revisions are identical."
* Expected: The old and new version of the link should be shown side-by-side

## Examples

The are two distinct versions of this error, and I haven't quite figured out when each is triggered. Here are examples:

### Variant A: Incorrect message "Both the revisions are identical."

Example: https://openlibrary.org/works/OL16816827W/Business_Integrity_Matters?_compare=Compare&b=5&a=4&m=diff says "...identical".

But, compare the two revisions:

[v4](https://openlibrary.org/works/OL16816827W/Business_Integrity_Matters?v=4) and [v5](https://openlibrary.org/works/OL16816827W/Business_Integrity_Matters?v=5)

...and you will note a change to the second link in the section _"Links outside Open Library"._ This is a link to Amazon that includes a spammy referral ID in **version 4** that is removed in **version 5**. The link text also changes from **"Purchase"** to **"Amazon"**.

### Variant B: Empty diff

Here is [another example](https://openlibrary.org/works/OL15528208W/Production_and_Operations_Management_Assignment?m=diff&b=5). In this case, the diff is simply empty, but the note _"...are identical"_ is not shown. The URL structure here is slightly different (parameters `a=4` and `_compare=Compare` are missing), but that does not seem to be relevant––these parameters do not seem to make any difference in either case. The actual change is, again, one link's target URL and anchor text being changed (more referral spam).

This only happens for *changes* to links. _Adding_ or _deleting_ links is handled correctly ([example](https://openlibrary.org/works/OL82588W/Inside_Hogwarts?m=diff&b=10))

### Details

- **Logged in (Y/N)?** Both
- **Browser type/version?** All of them
- **Operating system?** Doesn't matter, but MacOS
- **Environment (prod/dev/local)?** prod

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.