opensafely-core / opencodelists

OpenCodelists is an open platform for creating and sharing codelists of clinical terms and drugs.
https://www.opencodelists.org
Other
31 stars 9 forks source link

CodelistVersion.MultipleObjectsReturn in diff view with codelist version tag #1984

Open rebkwok opened 1 month ago

rebkwok commented 1 month ago

From sentry issue This error was raised by trying to diff this codelist with its previous version, tag 20201016.

The diff view accepts an other_tag_or_hash which it uses to filter the CodelistVersion to the one that should be diffed. However, while version hashes are unique, tags are not. For older codelists, there are many where the tag is a date or a version number, and they're the same across multiple codelist versions.

The diff view isn't documented (see #1148), but quite a lot of users know about it, and it's becoming useful now that we have coding system releases as a way to see how a codelist has changed between releases.

How to handles tags is tricky - you can diff codelist versions of different codelists, so you can't easily tell which tag the user intended to refer to. I'd say there are a few options: 1) Make diffs possible with version hashed ONLY (if we did that, we'd probably also want to display the version hashes on the codelist page as well as the tag, because currently users need to manually type the diff url) 2) Allow diffs by tag, but only within the same codelist (i.e. if the other_tag_or_hash is a tag, filter CodelistVersion by codelist as well as tag, which will be unique) 3) Keep behaviour as it is now, but handle the error if there's more than one matching tag, and show some message that tells the user to diff by hash instead