Issue Summary

A summary of the issue and the browser/OS environment in which it occurs.

Technical details:

  • Redash Version: v10
  • Browser/OS: Google Chrome
  • How did you install Redash: Kubernetes with Helm Chart

I cannot load schema on few databases on mongodb with unknown unicode decode bson
im using pymongo > 3.90
maybe i need some unicode_decode_error_handler (CMIIW) or some custom query runner mongodb
can anyone having same issue?

im can connect to the DB anyway but cannot load its schema
image

error log on scheduler worker :

Traceback (most recent call last):
File “/app/redash/tasks/queries/maintenance.py”, line 171, in refresh_schema
ds.get_schema(refresh=True)
File “/app/redash/models/init.py”, line 198, in get_schema
schema = query_runner.get_schema(get_stats=refresh)
File “/app/redash/query_runner/mongodb.py”, line 244, in get_schema
columns = self._get_collection_fields(db, collection_name)
File “/app/redash/query_runner/mongodb.py”, line 228, in _get_collection_fields
for d in db[collection_name].find().sort([(“$natural”, 1)]).limit(1):
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 1156, in next
if len(self.__data) or self._refresh():
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 1073, in _refresh
self.__send_message(q)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 955, in __send_message
address=self.__address)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/mongo_client.py”, line 1346, in _run_operation_with_response
exhaust=exhaust)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/mongo_client.py”, line 1464, in _retryable_read
return func(session, server, sock_info, slave_ok)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/mongo_client.py”, line 1340, in _cmd
unpack_res)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/server.py”, line 131, in run_operation_with_response
user_fields=user_fields)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 1030, in _unpack_response
legacy_response)
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/message.py”, line 1591, in unpack_response
self.payload_document, codec_options, user_fields)
File “/home/redash/.local/lib/python3.7/site-packages/bson/init.py”, line 1098, in _decode_all_selective
return decode_all(data, codec_options)
bson.errors.InvalidBSON: ‘utf-8’ codec can’t decode byte 0xd4 in position 1: invalid continuation byte

Thanks

I googled your error and found the fix: python - pymongo error: bson.errors.InvalidBSON: 'utf8' codec can't decode byte 0xa1 in position 25: invalid start byte - Stack Overflow

This will need to be applied to the mongo.py query runner. If the change works on your end, please open a pull request and we’ll merge it so that others can benefit also.