opensafely-core / opensafely-core/opensafely-cli

Detect poorly formatted user-owned codelists in codelists.txt

Open
#338 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2
Forks
5
Avg merge
2d 1h
Merged PRs (30d)
4

Description

A user encountered a See slack thread with from opensafely codelists check.

The codelists check does a very cursory check of whether a line in a user's codelist.txt file is properly formatted.

However, it basically only checks that the line contains either 3 or 4 terms separated by a /. If a user doesn't include a version id for a user-owned codelist (e.g. user/rebkwok/my-codelist instead of user/rebkwok/my-codelist/v1234), this check will pass, but multiple codelists from the same user will fail.

e.g. if my codelist.txt contains

user/rebkwok/my-codelist
user/rebkwok/my-codelist1

The check will accept these as valid codelist.txt entries (because they contain 3 elements when split on /), but it will interpret user/rebkwok as the codelist and my-codelist and my-codelist1 as the version, and it will report that there are conflicting codelist versions in the codelists.txt.

It should be quite easy to update this so that the codelist patterns in each line match either a valid user codelist pattern or a valid org pattern.

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 opensafely/codelists.py around line 350, where opensafely codelists check validates codelist.txt entries. Use the user-owned examples in the issue to trace how slash-separated parts are interpreted, then verify that both user-owned and organisation codelist patterns are handled correctly and that the conflicting-version error no longer occurs for valid entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
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.