ListSets requests leads to an unhandled exception when study.study_groups don't have 'study_group' key

Issue #18 resolved
Toni Sissala created an issue
  1. Insert the following record to an empty document store {"study_number": "study_1", "study_groups": [{"name": "some study group", "language": "en"}]}
  2. Request oai?verb=ListSets

Result: HTTP response 500

Traceback:

2020-06-04 11:45:03,026 ERROR(tornado.application): Uncaught exception GET /v0/oai?verb=ListSets (xxx.xxx.xxx.xxx)
HTTPServerRequest(protocol='http', host='xxx.xxx.xxx.xxx:7003', method='GET', uri='/v0/oai?verb=ListSets', version='HTTP/1.1', remote_ip='xxx.xxx.xxx.xxx')
Traceback (most recent call last):
File "venv/kuha_oai_pmh_repo_handler/lib/python3.5/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "kuha_oai_pmh_repo_handler/kuha_oai_pmh_repo_handler/handlers.py", line 269, in get
await self._router(args)
File "kuha_oai_pmh_repo_handler/kuha_oai_pmh_repo_handler/handlers.py", line 249, in _router
await route_callable()
File "kuha_oai_pmh_repo_handler/kuha_oai_pmh_repo_handler/genshi_loader.py", line 128, in wrapper
context = await ctx_func(ctx)
File "kuha_oai_pmh_repo_handler/kuha_oai_pmh_repo_handler/handlers.py", line 135, in list_sets
sets_list = get_sets_list_from_query_result(set, query_result)
File "kuha_oai_pmh_repo_handler/kuha_oai_pmh_repo_handler/oai/records.py", line 165, in get_sets_list_from_query_result
if record[set.record_field_setspec] is None
KeyError: 'study_group'

Expected HTTP Response 200 with ListSets response that discards the record’s setspec

Comments (1)

  1. Toni Sissala reporter

    Release 0.11.1

    • Check for query result item's set.record_field_setspec using item.get() since the item may not have such key and we wish to avoid KeyError. (Fixes #18)
    • Remove check for the record_field_setname since it is acceptable to have and OAI set without a setName.

    → <<cset 993e5c2d3900>>

  2. Log in to comment