opensafely-core / opensafely-core/opencodelists

Server error when converting a BNF codelists in some situations

Open
#2,886 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Why are we doing this?

There are situations where attempting to convert a BNF codelist to DM+D results in a 500 server error. If an identical dmd codelist already exists the code should display a banner to the end user with a link to the dmd file. However the code that attempts to get the link fails if there are multiple identical slugs (which can happen as they're only unique to a user or an org).

How will we know when it's done?

The conversion no longer returns an error but instead displays the banner linking back to the existing dmd codelist

What are we doing?

This line fails if there are multiple identical slugs:

https://github.com/opensafely-core/opencodelists/blob/877690d4b59d09a93b89841433e16a3d12751ebc/codelists/views/version_dmd_convert.py#L22

Instead we should scope it to the user or org, similar (but not identical) to this code here:

https://github.com/opensafely-core/opencodelists/blob/877690d4b59d09a93b89841433e16a3d12751ebc/codelists/actions.py#L760-L763

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 in codelists/views/version_dmd_convert.py at the failing line, then compare the scoping approach in codelists/actions.py around lines 760-763. Update the lookup so duplicate slugs are scoped to the relevant user or organisation. Done means conversion no longer returns a 500 error and displays a banner linking to the existing DM+D codelist.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.