<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>MongoDB decode bson codec pymongo - Self Hosted Redash Support - Redash Discourse</title>
    <meta name="description" content="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 canno&amp;hellip;">
    <meta name="generator" content="Discourse 3.2.0.beta2-dev - https://github.com/discourse/discourse version 83621ccbe797223b48b624b00ef04f24672e1f03">
<link rel="icon" type="image/png" href="https://global.discourse-cdn.com/standard17/uploads/redash1/optimized/1X/01e20869afc0877e3e5aee0f94419b9e9bffa961_2_32x32.ico">
<link rel="apple-touch-icon" type="image/png" href="https://global.discourse-cdn.com/standard17/uploads/redash1/optimized/1X/e1838a8a0c506503a22e0c60e2334374b2895c87_2_180x180.png">
<meta name="theme-color" media="all" content="#ffffff">

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover">
<link rel="canonical" href="https://discuss.redash.io/t/mongodb-decode-bson-codec-pymongo/10776" />

<link rel="search" type="application/opensearchdescription+xml" href="https://discuss.redash.io/opensearch.xml" title="Redash Discourse Search">

    <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/color_definitions_base__2_8fd59ae1f286f43b3ff17996df07ea951685249d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" class="light-scheme"/>

  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/desktop_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="desktop"  />



  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/checklist_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="checklist"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-adplugin_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-adplugin"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-akismet_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-akismet"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-cakeday_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-cakeday"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-chat-integration_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-chat-integration"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-details_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-details"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-footnote_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-footnote"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-lazy-videos_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-lazy-videos"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-local-dates_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-local-dates"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-narrative-bot_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-narrative-bot"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-presence_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-presence"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-solved_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-solved"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/discourse-spoiler-alert_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="discourse-spoiler-alert"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/hosted-site_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="hosted-site"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/poll_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="poll"  />
  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/poll_desktop_d86c892d7cd5311243d31a8f11787f4b0342874d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="poll_desktop"  />

  <link href="https://sjc6.discourse-cdn.com/standard17/stylesheets/desktop_theme_2_be4cb2b86ec06123c5e974acd20fd933d14b129d.css?__ws=discuss.redash.io" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="2" data-theme-name="default"/>

    
    <meta id="data-ga-universal-analytics" data-tracking-code="UA-47088186-6" data-json="{&quot;cookieDomain&quot;:&quot;auto&quot;}" data-auto-link-domains="">

  <link rel="preload" href="https://global.discourse-cdn.com/standard17/assets/google-universal-analytics-v3-08add7ec997ab472fcd9f821d32ff7caf4b8b9a5de2ec18ca723a040be07a098.gz.js" as="script">
<script defer src="https://global.discourse-cdn.com/standard17/assets/google-universal-analytics-v3-08add7ec997ab472fcd9f821d32ff7caf4b8b9a5de2ec18ca723a040be07a098.gz.js"></script>


        <link rel="alternate nofollow" type="application/rss+xml" title="RSS feed of &#39;MongoDB decode bson codec pymongo&#39;" href="https://discuss.redash.io/t/mongodb-decode-bson-codec-pymongo/10776.rss" />
    <meta property="og:site_name" content="Redash Discourse" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:image" content="https://global.discourse-cdn.com/standard17/uploads/redash1/original/2X/a/ae6e796261485dcab0b7c41ee8eebd3fe0e67947.png" />
<meta property="og:image" content="https://global.discourse-cdn.com/standard17/uploads/redash1/original/2X/a/ae6e796261485dcab0b7c41ee8eebd3fe0e67947.png" />
<meta property="og:url" content="https://discuss.redash.io/t/mongodb-decode-bson-codec-pymongo/10776" />
<meta name="twitter:url" content="https://discuss.redash.io/t/mongodb-decode-bson-codec-pymongo/10776" />
<meta property="og:title" content="MongoDB decode bson codec pymongo" />
<meta name="twitter:title" content="MongoDB decode bson codec pymongo" />
<meta property="og:description" content="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 &gt; 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 sche..." />
<meta name="twitter:description" content="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 &gt; 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 sche..." />
<meta property="og:article:section" content="Support" />
<meta property="og:article:section:color" content="BF1E2E" />
<meta property="og:article:section" content="Self Hosted Redash Support" />
<meta property="og:article:section:color" content="AB9364" />
<meta property="og:article:tag" content="mongodb" />
<meta property="article:published_time" content="2022-07-17T08:26:06+00:00" />
<meta property="og:ignore_canonical" content="true" />


    <script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"MongoDB decode bson codec pymongo","mainEntity":{"@type":"Question","name":"MongoDB decode bson codec pymongo","text":"<a name=\"issue-summary-1\" class=\"anchor\" href=\"#issue-summary-1\"><\/a>Issue Summary\n\nA summary of the issue and the browser/OS environment in which it occurs.\n\n<a name=\"technical-details-2\" class=\"anchor\" href=\"#technical-details-2\"><\/a>Technical details:\n\nRedash Version: v10\n\nBrowser/OS: Google Chrome\n\nHow did you install Redash: Kubernetes with Helm Chart\n\nI cannot load schema on few databases on mongodb with unknown unicode decode bson\n\nim u&hellip;","upvoteCount":0,"answerCount":0,"dateCreated":"2022-07-17T08:26:06.068Z","author":{"@type":"Person","name":"ndreaspp"}}}</script>
  </head>
  <body class="crawler ">
    
    <header>
  <a href="/">
    Redash Discourse
  </a>
</header>

    <div id="main-outlet" class="wrap" role="main">
        <div id="topic-title">
    <h1>
      <a href="/t/mongodb-decode-bson-codec-pymongo/10776">MongoDB decode bson codec pymongo</a>
    </h1>

      <div class="topic-category" itemscope itemtype="http://schema.org/BreadcrumbList">
          <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a href="https://discuss.redash.io/c/support/6" class="badge-wrapper bullet" itemprop="item">
              <span class='badge-category-bg' style='background-color: #BF1E2E'></span>
              <span class='badge-category clear-badge'>
                <span class='category-name' itemprop='name'>Support</span>
              </span>
            </a>
            <meta itemprop="position" content="1" />
          </span>
          <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a href="https://discuss.redash.io/c/support/support-self-hosted/9" class="badge-wrapper bullet" itemprop="item">
              <span class='badge-category-bg' style='background-color: #AB9364'></span>
              <span class='badge-category clear-badge'>
                <span class='category-name' itemprop='name'>Self Hosted Redash Support</span>
              </span>
            </a>
            <meta itemprop="position" content="2" />
          </span>
      </div>

      <div class="topic-category">
        <div class='discourse-tags list-tags'>
            <a href='https://discuss.redash.io/tag/mongodb' class='discourse-tag' rel="tag">mongodb</a>
        </div>
      </div>
  </div>

  

    <div itemscope itemtype='http://schema.org/DiscussionForumPosting'>
      <meta itemprop='headline' content='MongoDB decode bson codec pymongo'>
        <meta itemprop='articleSection' content='Self Hosted Redash Support'>
      <meta itemprop='keywords' content='mongodb'>
      <div itemprop='publisher' itemscope itemtype="http://schema.org/Organization">
        <meta itemprop='name' content='Redash Discourse'>
          <div itemprop='logo' itemscope itemtype="http://schema.org/ImageObject">
            <meta itemprop='url' content='https://global.discourse-cdn.com/standard17/uploads/redash1/original/1X/c07bc573841e1e4a0013ea3b6fe088a1534228a3.png'>
          </div>
      </div>

          <div id='post_1'  class='topic-body crawler-post'>
            <div class='crawler-post-meta'>
              <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person">
                <a itemprop="url" href='https://discuss.redash.io/u/ndreaspp'><span itemprop='name'>ndreaspp</span></a>
                
              </span>

              <link itemprop="mainEntityOfPage" href="https://discuss.redash.io/t/mongodb-decode-bson-codec-pymongo/10776">

                <link itemprop="image" href="https://global.discourse-cdn.com/standard17/uploads/redash1/original/2X/a/ae6e796261485dcab0b7c41ee8eebd3fe0e67947.png">

              <span class="crawler-post-infos">
                  <time itemprop='datePublished' datetime='2022-07-17T08:26:06Z' class='post-time'>
                    July 17, 2022,  8:26am
                  </time>
                  <meta itemprop='dateModified' content='2022-07-17T08:27:48Z'>
              <span itemprop='position'>1</span>
              </span>
            </div>
            <div class='post' itemprop='articleBody'>
              <h3>
<a name="issue-summary-1" class="anchor" href="#issue-summary-1"></a>Issue Summary</h3>
<p>A summary of the issue and the browser/OS environment in which it occurs.</p>
<h3>
<a name="technical-details-2" class="anchor" href="#technical-details-2"></a>Technical details:</h3>
<ul>
<li>Redash Version: v10</li>
<li>Browser/OS: Google Chrome</li>
<li>How did you install Redash: Kubernetes with Helm Chart</li>
</ul>
<p>I cannot load schema on few databases on mongodb with unknown unicode decode bson<br>
im using pymongo &gt; 3.90<br>
maybe i need some unicode_decode_error_handler (CMIIW) or some custom query runner mongodb<br>
can anyone having same issue?</p>
<p>im can connect to the DB anyway but cannot load its schema<br>
<img src="https://global.discourse-cdn.com/standard17/uploads/redash1/original/2X/a/ae6e796261485dcab0b7c41ee8eebd3fe0e67947.png" alt="image" data-base62-sha1="oT5LIwR2gT0ADdiqqojDK1PuThJ" width="303" height="87"></p>
<p>error log on scheduler worker :</p>
<blockquote>
<p>Traceback (most recent call last):<br>
File “/app/redash/tasks/queries/maintenance.py”, line 171, in refresh_schema<br>
ds.get_schema(refresh=True)<br>
File “/app/redash/models/<strong>init</strong>.py”, line 198, in get_schema<br>
schema = query_runner.get_schema(get_stats=refresh)<br>
File “/app/redash/query_runner/mongodb.py”, line 244, in get_schema<br>
columns = self._get_collection_fields(db, collection_name)<br>
File “/app/redash/query_runner/mongodb.py”, line 228, in _get_collection_fields<br>
for d in db[collection_name].find().sort([(“$natural”, 1)]).limit(1):<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 1156, in next<br>
if len(self.__data) or self._refresh():<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 1073, in _refresh<br>
self.__send_message(q)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 955, in __send_message<br>
address=self.__address)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/mongo_client.py”, line 1346, in _run_operation_with_response<br>
exhaust=exhaust)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/mongo_client.py”, line 1464, in _retryable_read<br>
return func(session, server, sock_info, slave_ok)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/mongo_client.py”, line 1340, in _cmd<br>
unpack_res)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/server.py”, line 131, in run_operation_with_response<br>
user_fields=user_fields)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/cursor.py”, line 1030, in _unpack_response<br>
legacy_response)<br>
File “/home/redash/.local/lib/python3.7/site-packages/pymongo/message.py”, line 1591, in unpack_response<br>
self.payload_document, codec_options, user_fields)<br>
File “/home/redash/.local/lib/python3.7/site-packages/bson/<strong>init</strong>.py”, line 1098, in _decode_all_selective<br>
return decode_all(data, codec_options)<br>
bson.errors.InvalidBSON: ‘utf-8’ codec can’t decode byte 0xd4 in position 1: invalid continuation byte</p>
</blockquote>
<p>Thanks</p>
            </div>

            <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">
              <meta itemprop="interactionType" content="http://schema.org/LikeAction"/>
              <meta itemprop="userInteractionCount" content="0" />
              <span class='post-likes'></span>
            </div>

            <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">
                <meta itemprop="interactionType" content="http://schema.org/CommentAction"/>
                <meta itemprop="userInteractionCount" content="0" />
              </div>

          </div>
          <div id='post_2' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'>
            <div class='crawler-post-meta'>
              <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person">
                <a itemprop="url" href='https://discuss.redash.io/u/jesse'><span itemprop='name'>jesse</span></a>
                
              </span>

              <link itemprop="mainEntityOfPage" href="https://discuss.redash.io/t/mongodb-decode-bson-codec-pymongo/10776">


              <span class="crawler-post-infos">
                  <time itemprop='datePublished' datetime='2022-07-18T14:27:02Z' class='post-time'>
                    July 18, 2022,  2:27pm
                  </time>
                  <meta itemprop='dateModified' content='2022-07-18T14:27:02Z'>
              <span itemprop='position'>2</span>
              </span>
            </div>
            <div class='post' itemprop='text'>
              <p>I googled your error and found the fix: <a href="https://stackoverflow.com/questions/36314776/pymongo-error-bson-errors-invalidbson-utf8-codec-cant-decode-byte-0xa1-in-p" class="inline-onebox">python - pymongo error: bson.errors.InvalidBSON: 'utf8' codec can't decode byte 0xa1 in position 25: invalid start byte - Stack Overflow</a></p>
<p>This will need to be applied to the <code>mongo.py</code> 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.</p>
            </div>

            <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">
              <meta itemprop="interactionType" content="http://schema.org/LikeAction"/>
              <meta itemprop="userInteractionCount" content="0" />
              <span class='post-likes'></span>
            </div>

            <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter">
                <meta itemprop="interactionType" content="http://schema.org/CommentAction"/>
                <meta itemprop="userInteractionCount" content="0" />
              </div>

          </div>
    </div>






    </div>
    <footer class="container wrap">
  <nav class='crawler-nav'>
    <ul>
      <li itemscope itemtype='http://schema.org/SiteNavigationElement'>
        <span itemprop='name'>
          <a href='/' itemprop="url">Home </a>
        </span>
      </li>
      <li itemscope itemtype='http://schema.org/SiteNavigationElement'>
        <span itemprop='name'>
          <a href='/categories' itemprop="url">Categories </a>
        </span>
      </li>
      <li itemscope itemtype='http://schema.org/SiteNavigationElement'>
        <span itemprop='name'>
          <a href='/guidelines' itemprop="url">FAQ/Guidelines </a>
        </span>
      </li>
        <li itemscope itemtype='http://schema.org/SiteNavigationElement'>
          <span itemprop='name'>
            <a href='http://redash.io/terms.html' itemprop="url">Terms of Service </a>
          </span>
        </li>
        <li itemscope itemtype='http://schema.org/SiteNavigationElement'>
          <span itemprop='name'>
            <a href='http://redash.io/privacy.html' itemprop="url">Privacy Policy </a>
          </span>
        </li>
    </ul>
  </nav>
  <p class='powered-by-link'>Powered by <a href="https://www.discourse.org">Discourse</a>, best viewed with JavaScript enabled</p>
</footer>

    
    
  </body>
  
</html>