opensafely-core / opensafely-core/opencodelists

CodelistVersion.MultipleObjectsReturn in diff view with codelist version tag

Open
#1,984 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
60
Forks
16
Avg merge
4d 12h
Merged PRs (30d)
17

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the diff view handling for the other_tag_or_hash parameter and reproduce the CodelistVersion.MultipleObjectsReturn error using the codelist and tag from the report. Review the three proposed approaches, then confirm that the chosen behavior handles duplicate tags and gives users a reliable way to complete a diff.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.