<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:46:37 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>[CSHARP-3896] [IMongoCollection.UpdateOne] Element name is not valid</title>
                <link>https://jira.mongodb.org/browse/CSHARP-3896</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Hello!&lt;br/&gt;
I`ve faced the following exception during document updating using&#160;ObjectUpdateDefinition.&lt;br/&gt;
Is that a bug, or have I just used&#160;ObjectUpdateDefinition incorrectly?&lt;br/&gt;
If that`s not a bug, the behavior seems very suspicious, because I use&#160;ObjectUpdateDefinition in a very intuitive way for EF-experienced ones.&lt;br/&gt;
The full source code to reproduce is available &lt;a href=&quot;https://gist.github.com/UGeneF/ff57836ac84929acdd9162771c39a343&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Error formatting macro: code: java.lang.StackOverflowError&lt;/span&gt; 
&lt;p&gt;Unhandled exception. MongoDB.Bson.BsonSerializationException: Element name &apos;name&apos; is not valid&apos;. at MongoDB.Driver.Core.Connections.BinaryConnection.SendMessagesAsync(IEnumerable`1 messages, MessageEncoderSettings messageEncod erSettings, CancellationToken cancellationToken) at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.PooledConnection.SendMessagesAsync(IEnumerable`1 messages, Message EncoderSettings messageEncoderSettings, CancellationToken cancellationToken) at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationTok en cancellationToken) at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocolAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(IWireProtocol`1 protocol, ICoreSession session, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.RetryableWriteOperationExecutor.ExecuteAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(IRetryableWriteOperation`1 operation, Ret ryableWriteContext context, CancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase`1.ExecuteBatchAsync(RetryableWriteContext context, Batch batch, C ancellationToken cancellationToken) at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase`1.ExecuteBatchesAsync(RetryableWriteContext context, Cancellation Token cancellationToken) at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteBatchAsync(RetryableWriteContext context, Batch batch, Cancellat ionToken cancellationToken) at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken ) at MongoDB.Driver.OperationExecutor.ExecuteWriteOperationAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(IWriteBinding binding, IWriteOperation`1 operation, Cance llationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.ExecuteWriteOperationAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(IClientSessionHandle session, IWriteOperation`1 opera tion, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.BulkWriteAsync(IClientSessionHandle session, IEnumerable`1 requests, BulkWriteOptions opt ions, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(Func`2 funcAsync, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionBase`1.UpdateOneAsync(FilterDefinition`1 filter, UpdateDefinition`1 update, UpdateOptions option s, Func`3 bulkWriteAsync) at Sandbox.YetAnother.Program.Main() in C:\Users\Ugenef\RiderProjects\Sandbox\Sandbox.YetAnother\Program.cs:line 30 at Sandbox.YetAnother.Program.&amp;lt;Main&amp;gt;()&lt;/p&gt;&lt;/div&gt;</description>
                <environment></environment>
        <key id="1892224">CSHARP-3896</key>
            <summary>[IMongoCollection.UpdateOne] Element name is not valid</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</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="13202">Works as Designed</resolution>
                                        <assignee username="james.kovacs@mongodb.com">James Kovacs</assignee>
                                    <reporter username="evgenyfirstoff@gmail.com">Eugene F.</reporter>
                        <labels>
                    </labels>
                <created>Thu, 7 Oct 2021 03:14:24 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:43 +0000</updated>
                            <resolved>Wed, 13 Oct 2021 22:30:05 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4122930" author="james.kovacs" created="Wed, 13 Oct 2021 22:29:44 +0000"  >&lt;p&gt;Hi, Eugene,&lt;/p&gt;

&lt;p&gt;Glad that you got your example working. Yes, &lt;tt&gt;ObjectUpdateDefinition&amp;lt;T&amp;gt;&lt;/tt&gt; can lead to some confusion. Changing the visibility of a public type is a breaking API change. We will consider this and others for the 3.0 release. Thanks for the feedback.&lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br/&gt;
James&lt;/p&gt;</comment>
                            <comment id="4114321" author="JIRAUSER1262758" created="Sat, 9 Oct 2021 04:09:40 +0000"  >&lt;p&gt;Thank you for the answer, James!&lt;/p&gt;

&lt;p&gt;I tried your example code and it works.&lt;br/&gt;
I`ve no more questions regarding this issue.&lt;/p&gt;

&lt;p&gt;Deleting of `ObjectUpdateDefinition&amp;lt;T&amp;gt;` from the public API (or, at least, explaining its internal purpose in a comment, like Mircosoft devs love to do), perhaps, could be beneficial because people like me who are used to EF-style updates try to look for the familiar behavior in the Mongo Driver and find this one &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;Thanks again,&lt;br/&gt;
 Eugene&lt;/p&gt;</comment>
                            <comment id="4113663" author="james.kovacs" created="Fri, 8 Oct 2021 18:24:49 +0000"  >&lt;p&gt;Hi, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=evgenyfirstoff%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;evgenyfirstoff@gmail.com&quot;&gt;evgenyfirstoff@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thank you for reaching out to us regarding this issue and providing a repro.&lt;/p&gt;

&lt;p&gt;Examining the reproduction code, you are using &lt;tt&gt;ObjectUpdateDefinition&amp;lt;T&amp;gt;&lt;/tt&gt; in a way in which it was never intended. This class is used internally when working with wrapped &lt;tt&gt;BsonDocuments&lt;/tt&gt; to specify updates. It was never intended to be used to specify the replacement or updated object, though I can totally understand your confusion. It should likely have never been included as part of the public API.&lt;/p&gt;

&lt;p&gt;You can use the Builder API to create the correct `UpdateDefinition&amp;lt;T&amp;gt;` as follows:&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;var update = Builders&amp;lt;User&amp;gt;.Update&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;                           .Set(x =&amp;gt; x.Age, 3);&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;await collection.UpdateOneAsync(u =&amp;gt; u.Name == &quot;Jack&quot;, update);&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;For more information and examples please see &lt;a href=&quot;https://mongodb.github.io/mongo-csharp-driver/2.13/reference/driver/definitions/#updates&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Updates&lt;/a&gt; and &lt;a href=&quot;https://mongodb.github.io/mongo-csharp-driver/2.13/reference/driver/definitions/#update-definition-builder&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Update Definition Builder&lt;/a&gt; in our documentation.&lt;/p&gt;

&lt;p&gt;Please let us know if you have any additional questions.&lt;/p&gt;

&lt;p&gt;Sincerely,&lt;br/&gt;
James&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|hzoelr:</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>