<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:14:39 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CDRIVER-2250] Using bson that contains UTF-8 strings with null bytes fails</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-2250</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;We ran into this when writing a Rust wrapper around libmongoc: &lt;a href=&quot;https://github.com/thijsc/mongo-rust-driver&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/thijsc/mongo-rust-driver&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We use the bson Rust library to prepare bson byte arrays that get converted to libmongoc bsons using bson_new_from_data. This happens here: &lt;a href=&quot;https://github.com/thijsc/mongo-rust-driver/blob/master/src/bsonc.rs#L31&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/thijsc/mongo-rust-driver/blob/master/src/bsonc.rs#L31&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Rust strings in the bson are converted to bson strings, these can contain null bytes as is allowed in the bson spec. When you try to insert these documents with either a normal insert or a bulk operation the insert fails with this error: &quot;replacement document contains invalid keys)&quot;.&lt;/p&gt;

&lt;p&gt;After debugging this it looks like libmongoc sets the allow_null option to false when validating bson. I&apos;ve found no way to override this. It seems like we should just be able to use this bson byte array, since it conforms to the spec. How could we call normal inserts and bulk operations in such a way they will allow this bson?&lt;/p&gt;</description>
                <environment></environment>
        <key id="419838">CDRIVER-2250</key>
            <summary>Using bson that contains UTF-8 strings with null bytes fails</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="13201">Fixed</resolution>
                                        <assignee username="bjori">Hannes Magnusson</assignee>
                                    <reporter username="thijs">Thijs Cadier</reporter>
                        <labels>
                    </labels>
                <created>Thu, 24 Aug 2017 13:53:42 +0000</created>
                <updated>Sat, 28 Oct 2023 11:30:31 +0000</updated>
                            <resolved>Fri, 25 Aug 2017 20:50:15 +0000</resolved>
                                    <version>1.6.3</version>
                    <version>1.7.0</version>
                                    <fixVersion>1.8.0</fixVersion>
                                    <component>libbson</component>
                    <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1657631" author="xgen-internal-githook" created="Fri, 25 Aug 2017 20:49:59 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;bjori@php.net&apos;, &apos;name&apos;: &apos;Hannes Magnusson&apos;, &apos;username&apos;: &apos;bjori&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt; nModified is not available in MongoDB 2.4&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/7d24183ab5794b51a156911ea9cb49cfd887c5bb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/7d24183ab5794b51a156911ea9cb49cfd887c5bb&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1657593" author="xgen-internal-githook" created="Fri, 25 Aug 2017 20:12:59 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;bjori@php.net&apos;, &apos;name&apos;: &apos;Hannes Magnusson&apos;, &apos;username&apos;: &apos;bjori&apos;}
&lt;p&gt;Message: Merge branch &apos;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt;-null-value-in-strings&apos;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt;-null-value-in-strings:&lt;br/&gt;
  &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt; Cannot insert strings with null bytes&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/32442ad23a0c28b9eab7c74643bdd50946e084dc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/32442ad23a0c28b9eab7c74643bdd50946e084dc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="1657592" author="xgen-internal-githook" created="Fri, 25 Aug 2017 20:12:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;bjori@php.net&apos;, &apos;name&apos;: &apos;Hannes Magnusson&apos;, &apos;username&apos;: &apos;bjori&apos;}
&lt;p&gt;Message: Merge branch &apos;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt;-null-value-in-strings&apos;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt;-null-value-in-strings:&lt;br/&gt;
  &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt; Cannot insert strings with null bytes&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/32442ad23a0c28b9eab7c74643bdd50946e084dc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/32442ad23a0c28b9eab7c74643bdd50946e084dc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="1657591" author="xgen-internal-githook" created="Fri, 25 Aug 2017 20:12:57 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;bjori@php.net&apos;, &apos;name&apos;: &apos;Hannes Magnusson&apos;, &apos;username&apos;: &apos;bjori&apos;}
&lt;p&gt;Message: Merge branch &apos;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt;-null-value-in-strings&apos;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt;-null-value-in-strings:&lt;br/&gt;
  &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt; Cannot insert strings with null bytes&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/32442ad23a0c28b9eab7c74643bdd50946e084dc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/32442ad23a0c28b9eab7c74643bdd50946e084dc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="1657590" author="xgen-internal-githook" created="Fri, 25 Aug 2017 20:12:56 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;bjori@php.net&apos;, &apos;name&apos;: &apos;Hannes Magnusson&apos;, &apos;username&apos;: &apos;bjori&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2250&quot; title=&quot;Using bson that contains UTF-8 strings with null bytes fails&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2250&quot;&gt;&lt;del&gt;CDRIVER-2250&lt;/del&gt;&lt;/a&gt; Cannot insert strings with null bytes&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/cee8946363eb9286eea6b9191350343965cdaadd&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/cee8946363eb9286eea6b9191350343965cdaadd&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1656251" author="bjori" created="Thu, 24 Aug 2017 16:06:15 +0000"  >&lt;p&gt;You are right. The validation thats done on inserts is missing BSON_VALIDATE_UTF_ALLOW_NULL&lt;/p&gt;</comment>
                            <comment id="1656068" author="thijs" created="Thu, 24 Aug 2017 14:02:25 +0000"  >&lt;p&gt;There&apos;s a test for this here: &lt;a href=&quot;https://github.com/thijsc/mongo-rust-driver/pull/32/files#diff-5e55f18430efd105430896e3da14fdc1L77&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/thijsc/mongo-rust-driver/pull/32/files#diff-5e55f18430efd105430896e3da14fdc1L77&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I fully disable bson validation it passed, if I enable it it fails. For bulk operations I haven&apos;t gotten it to work at all.&lt;/p&gt;</comment>
                            <comment id="1656062" author="thijs" created="Thu, 24 Aug 2017 13:59:34 +0000"  >&lt;p&gt;The field name contain no nulls, only the values.&lt;/p&gt;</comment>
                            <comment id="1656055" author="jesse" created="Thu, 24 Aug 2017 13:57:04 +0000"  >&lt;p&gt;The field names include NULLs, or only the values? Field names can&apos;t include NULL, although bsonspec.org merely implies that restriction instead of stating it explicitly.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|ht5ddz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>