opensafely-core / opensafely-core/opencodelists

`do_search` AssertionError

Open
#1,998 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

We have received the following Sentry alert
https://ebm-datalab.sentry.io/issues/5558668558/?alert_rule_id=1877862&alert_type=issue&notification_uuid=088429c9-a418-4ad0-9892-9b56431d5f9d&project=5248013&referrer=slack

def do_search(coding_system, term=None, code=None):
    assert bool(code) != bool(term)
    if term is not None:
        matching_codes = coding_system.search_by_term(term)
    else:
        matching_codes = coding_system.search_by_code(code)

It's not clear what to do as a result of this exception. I think the code and term may be provided by users, in which case we should return a message to them. If not, we should probably raise a more informative error or find a way to stop it from happening.

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 with the do_search function shown in the issue and trace its callers to determine whether code and term can come from users. Review the linked Sentry alert to understand the failing input and decide whether to validate the inputs or raise a more informative error. Done means the reported AssertionError path has a defined, user-appropriate outcome.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.