opensafely-core / opensafely-core/opencodelists

Return a 404 when a `dmd-download.csv` request is made for a non-BNF codelist

Open
#3,183 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Why are we doing this?

We had a Sentry alert on Weds 29th July as a result of a number of requests to:

/codelist/{organisation_slug}/{codelist_slug}/{tag_or_hash}/dmd-download.csv

The dmd-download.csv view assumes it is being called for a BNF-based codelist. However, these requests were made for non-BNF codelists. For example:

When the view attempts to generate the download, it calls dmd_csv_data_for_download(), which asserts that the codelist is BNF-based. This raises an AssertionError, causing the request to return a 500.

From the investigation, it appears these requests were made directly to the endpoint (likely automated probing), rather than via the OpenCodelists UI. A full write-up of the investigation is available in the Slack thread here.

The endpoint currently returns a 500 for a request that cannot succeed. We should decide whether to:

  • return a more appropriate response (for example, 404 not found), or
  • leave the current behaviour unchanged.

We have had another Sentry alert today (Mon 3rd Aug) due to the above issue.

How will we know when it's done?

  • We've decided whether to change the behaviour of this endpoint.
  • If we're making a change, it has been implemented and deployed.
  • If we're not making a change, we've documented the decision in this issue.
  • The related Sentry issue has been archived or resolved, as appropriate.

What are we doing?

  • Decide whether we want to change the behaviour of this endpoint.
  • If so, implement the agreed change; otherwise, document the decision to leave the current behaviour unchanged.
  • Archive or resolve the Sentry issue, depending on the outcome.

Defining delivery tasks guidance

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 tracing the dmd-download.csv view and its call to dmd_csv_data_for_download(), which currently asserts that the codelist is BNF-based. Review the issue's proposed 404 behaviour before deciding the endpoint's response for non-BNF codelists. Done means the behaviour is implemented and deployed or the decision is documented, and the related Sentry issue is resolved or archived.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.