opensafely-core / opensafely-core/opencodelists

Bug report: Many Cached hierarchies often do not reflect the current CodelistVersion state

Open
#3,038 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

Many cached hierarchies do not reflect the current state of a CodelistVersion, leading to incorrect assertions regarding the CodelistVersion's CodingSystemRelease compatibility.

What did you do and what did you expect to happen?

Expectation:

>>> cv = CodelistVersion.objects.get_by_hash("3f51e9b7")
>>> cv.hierarchy == cv.calculate_hierarchy(cv.coding_system)
True

Counter-example:

>>> cv = CodelistVersion.objects.get_by_hash("5b45576f")
>>> cv.hierarchy == cv.calculate_hierarchy(cv.coding_system)
False

Impact of the bug

When loading a new CodingSystemRelease, a CodelistVersion's cached hierarchy is compared against one calculated using the incoming release. Whether or not they are found to be the same is considered as part of whether the CodelistVersion is "compatible" with the release.

If the cached hierarchy is an inaccurate representation of the current state of the CodelistVersion, then it may lead to incorrect assertions of incompatibility of the version with a release.

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

Reproduce the two CodelistVersion examples using the hashes in the issue and compare hierarchy with calculate_hierarchy(cv.coding_system). Trace how the cached hierarchy is stored or refreshed, then add coverage showing it matches the current CodelistVersion state and no longer produces incorrect compatibility results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.