opensafely-core / opencodelists

OpenCodelists is an open platform for creating and sharing codelists of clinical terms and drugs.
https://www.opencodelists.org
Other
31 stars 11 forks source link

`do_search` AssertionError #1998

Open lucyb opened 3 months ago

lucyb commented 3 months ago

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.