OpenDataServices / org-ids

Front end application for http://org-id.guide
http://org-id.guide
Other
17 stars 9 forks source link

KeyError for subnational lookup #186

Closed Bjwebb closed 6 years ago

Bjwebb commented 6 years ago

I get this error when trying to run master locally (for any query):

Traceback:
File "/home/bjwebb/opendataservices/org-ids/.ve/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response
  132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/bjwebb/opendataservices/org-ids/prefix_finder/frontend/views.py" in results
  486.         'all_results': filter_and_score_results(query, branch)
File "/home/bjwebb/opendataservices/org-ids/prefix_finder/frontend/views.py" in filter_and_score_results
  324.         add_titles(value)
File "/home/bjwebb/opendataservices/org-ids/prefix_finder/frontend/views.py" in add_titles
  165.             subnational_coverage.extend(lookups['subnational'][country])

Exception Type: KeyError at /results
Exception Value: 'GB'

I also get the error on the dev site http://dev.org-id.guide/results https://sentry.io/open-data-services/org-ids-dev/issues/431099178/ I think this could be due to this merge into the register repo: https://github.com/org-id/register/commit/6a2d0a822a50b893302480a7820aabbc404df2d9 I don't see the problem on the live site, but I suspect that's due to caching.

Bjwebb commented 6 years ago

If I undo those changes the problem goes away http://dev.org-id.guide/_preview_branch/reset-subnational-merge

edugomez commented 6 years ago

If I undo those changes the problem goes away http://dev.org-id.guide/_preview_branch/reset-subnational-merge

I noticed that already. The funny thing is it seems to be only for GB (AFAIK, any other country seems to work). I'm investigating right now

edugomez commented 6 years ago

I was wrong, it breaks for a number of countries (but not all of them)

edugomez commented 6 years ago

@Bjwebb I found the problem, completely my fault. I used a local script to convert to the data structure in codelist-coverage.json from the data I was collating for subnational division, A bug in the script added titles instead of codes, so e.g.

    {
      "code": "GE-AB", 
      "countryCode": "Georgia", 
      "title": {
        "en": "Abkhazia"
      }

when it should be

    {
      "code": "GE-AB", 
      "countryCode": "GE", 
      "title": {
        "en": "Abkhazia"
      }

Will submit a PR to the register

edugomez commented 6 years ago

This PR in org-id/register should fix it https://github.com/org-id/register/pull/169