<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:11:36 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-1111] Provide error feedback for invalid newObj arg to update/replace functions</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-1111</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;Discovered while working on an edge case in &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-550&quot; title=&quot;Always encode ODS field when serializing Persistable documents&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-550&quot;&gt;&lt;del&gt;PHPC-550&lt;/del&gt;&lt;/a&gt;, where the driver would sometimes inject a regular field name into a atomic modifier object. While that&apos;s certainly a bug to fix, it&apos;s possible that users may trigger this (from the driver, not our high-level library, where we check for it) by providing their own malformed &lt;tt&gt;newObj&lt;/tt&gt; documents.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If BulkWrite always encodes the ODS field, &lt;tt&gt;bsonSerialize()&lt;/tt&gt; is now unable to return atomic updates. Worse yet, the &lt;tt&gt;&amp;#95;_pclass&lt;/tt&gt; field gets added into the document with atomic modifiers, which causes &lt;tt&gt;BulkWrite::update()&lt;/tt&gt; to detect the document as a replacement due to:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;while (bson_iter_next (&amp;amp;iter)) {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    if (!strchr (bson_iter_key (&amp;amp;iter), &apos;$&apos;)) {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        mongoc_bulk_operation_replace_one(intern-&amp;gt;bulk, bquery, bupdate, !!(flags &amp;amp; MONGOC_UPDATE_UPSERT));&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        replaced = 1;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;        break;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;    }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;In turn, &lt;tt&gt;mongoc_bulk_operation_replace_one()&lt;/tt&gt; actually fails silently (apart from a &lt;tt&gt;MONGOC_WARNING()&lt;/tt&gt; which only surfaces in PHP with &lt;tt&gt;mongodb.debug&lt;/tt&gt; enabled) and refuses to add the update to its command document. I noticed this when executing the BulkWrite failed due to being empty. If there were other writes scheduled, that update would simply be ignored, which would be much harder to catch. Independent of this ticket, we should certainly add some better error reporting around this, even if it means validating the document on our own before libmongoc does so again.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;&lt;tt&gt;MONGOC_WARNING()&lt;/tt&gt; does not seem suitable for relaying these errors (at least if a wrapping driver wishes to capture them and throw an exception). Since the functions are &lt;tt&gt;void&lt;/tt&gt; and take no output parameters, there likely isn&apos;t a good way to introduce error reporting without an ABI change.&lt;/p&gt;

&lt;p&gt;As a temporary work-around, I suppose the PHP driver can manually validate the BSON itself, as is done in the libmongoc functions before the warning might be logged.&lt;/p&gt;</description>
                <environment></environment>
        <key id="264891">CDRIVER-1111</key>
            <summary>Provide error feedback for invalid newObj arg to update/replace functions</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</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="3">Duplicate</resolution>
                                        <assignee username="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                    </labels>
                <created>Thu, 11 Feb 2016 21:08:16 +0000</created>
                <updated>Mon, 30 Jan 2017 18:35:22 +0000</updated>
                            <resolved>Mon, 30 Jan 2017 18:35:10 +0000</resolved>
                                    <version>1.3.3</version>
                                    <fixVersion>1.6.0</fixVersion>
                                    <component>Bulk API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1171435" author="jesse" created="Fri, 12 Feb 2016 03:28:16 +0000"  >&lt;p&gt;Yeah, PyMongo raises an exception directly from &lt;tt&gt;BulkOperation.replace_one(replacement)&lt;/tt&gt; if the &quot;replacement&quot; document has any fields that contain $-signs. We can&apos;t communicate errors from &lt;tt&gt;mongoc_bulk_operation_replace_one&lt;/tt&gt;, though.&lt;/p&gt;

&lt;p&gt;It might be appropriate in a 1.x release to set an internal &lt;tt&gt;mongoc_bulk_operation_t.error&lt;/tt&gt; if we get an invalid input. &lt;tt&gt;mongoc_bulk_operation_execute&lt;/tt&gt; to fails with a useful error about the &lt;b&gt;first&lt;/b&gt; invalid operation added to the bulk op.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="295884">CDRIVER-1341</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="264906">PHPC-579</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="260756">PHPC-550</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <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|hsiblz:</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>