distinct query where fieldname points to nested _metadata attribute leads to 500
Reproduce:
Make a HTTP request using query-type 'distinct' and point fieldname to a nested _metadata attribute.
curl "localhost:6001/v0/query/studies?query_type=distinct" -H "Content-Type: application/json" --data '{"fieldname": "_metadata.schema_version"}'
Response:
{"code": 500, "message": "Internal Server Error"}
Docstore log:
Traceback (most recent call last):
File "/kuha_document_store-env/lib/python3.12/site-packages/tornado/web.py", line 1790, in _execute
result = await result
^^^^^^^^^^^^
File "/kuha_document_store-env/lib/python3.12/site-packages/kuha_document_store/handlers.py", line 288, in post
result = await self.get_db().query_distinct(collection, fieldname, _filter)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/kuha_document_store-env/lib/python3.12/site-packages/kuha_document_store/database.py", line 701, in query_distinct
dig_and_set(results, path, datetime_to_datestamp, allow_none=True)
File "/kuha_document_store-env/lib/python3.12/site-packages/kuha_common/document_store/records.py", line 142, in dig_and_set
dig_and_set(item, path_join(*keys[index:]), replacement, allow_none)
File "/kuha_document_store-env/lib/python3.12/site-packages/kuha_common/document_store/records.py", line 142, in dig_and_set
dig_and_set(item, path_join(*keys[index:]), replacement, allow_none)
File "/kuha_document_store-env/lib/python3.12/site-packages/kuha_common/document_store/records.py", line 142, in dig_and_set
dig_and_set(item, path_join(*keys[index:]), replacement, allow_none)
[Previous line repeated 986 more times]
File "/kuha_document_store-env/lib/python3.12/site-packages/kuha_common/document_store/records.py", line 136, in dig_and_set
keys = path_split(path)
^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded
Expected response would return distinct values of requested field.
This is actually a bug in Kuha Common and is fixed in kuha_common@080497ba
Edited by Toni Sissala