<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:48:38 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-4570] dynamic type BsonSerializationException</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4570</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;h4&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h4&gt;

&lt;p&gt;NET8, I found a problem. Dynamic type of data can not be inserted into the database, but switch the SDK to 7.0 or 6.0, the problem remains. Then I tried to downgrade MongoDriverc from 2.19.0 to 2.18.0 and the problem disappeared.&lt;/p&gt;

&lt;p&gt;Problem Reproduction Code:&#160;&lt;a href=&quot;https://github.com/joesdu/MongoIssue&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Error Log:&lt;/b&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;23%3A18%3A14ERRMongoDB.Bson.BsonSerializationException%3AType%3C%3EfAnonymousType1%603System.String%2CSystem.Private.CoreLib%2CVersion%3D8.0.0.0%2CCulture%3Dneutral%2CPublicKeyToken%3D7cec85d7bea7798e%2CSystem.Int32%2CSystem.Private.CoreLib%2CVersion%3D8.0.0.0%2C%3C%2F%3E...&quot;&gt;&lt;/a&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;23:18:14 ERR&amp;#93;&lt;/span&gt; MongoDB.Bson.BsonSerializationException: Type &amp;lt;&amp;gt;f__AnonymousType1`3[&lt;span class=&quot;error&quot;&gt;&amp;#91;System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&amp;#93;&lt;/span&gt;,[System.Collections.Generic.List`1[&lt;span class=&quot;error&quot;&gt;&amp;#91;System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e&amp;#93;&lt;/span&gt;], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] is not configured as an allowed type for this instance of ObjectSerializer.&lt;/h4&gt;
&lt;p&gt;&#160; &#160;at MongoDB.Bson.Serialization.Serializers.ObjectSerializer.SerializeDiscriminatedValue(BsonSerializationContext context, BsonSerializationArgs args, Object value, Type actualType)&lt;br/&gt;
&#160; &#160;at MongoDB.Bson.Serialization.Serializers.ObjectSerializer.Serialize(BsonSerializationContext context, BsonSerializationArgs args, Object value)&lt;br/&gt;
&#160; &#160;at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize(IBsonSerializer serializer, BsonSerializationContext context, Object value)&lt;br/&gt;
&#160; &#160;at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize(IBsonSerializer serializer, BsonSerializationContext context, Object value)&lt;br/&gt;
&#160; &#160;at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize(IBsonSerializer serializer, BsonSerializationContext context, Object value)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CommandMessageBinaryEncoder.WriteType1Section(BsonBinaryWriter writer, Type1CommandMessageSection section, Int64 messageStartPosition)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CommandMessageBinaryEncoder.WriteSection(BsonBinaryWriter writer, CommandMessageSection section, Int64 messageStartPosition)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CommandMessageBinaryEncoder.WriteSections(BsonBinaryWriter writer, IEnumerable`1 sections, Int64 messageStartPosition)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CommandMessageBinaryEncoder.WriteMessage(CommandMessage message)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CommandRequestMessageBinaryEncoder.WriteMessage(CommandRequestMessage message)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CommandRequestMessageBinaryEncoder.MongoDB.Driver.Core.WireProtocol.Messages.Encoders.IMessageEncoder.WriteMessage(MongoDBMessage message)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.Connections.BinaryConnection.SendMessagesHelper.EncodeMessages(CancellationToken cancellationToken, List`1&amp;amp; sentMessages)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.Connections.BinaryConnection.SendMessagesAsync(IEnumerable`1 messages, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.PooledConnection.SendMessagesAsync(IEnumerable`1 messages, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;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)&lt;br/&gt;
&#160; &#160;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, RetryableWriteContext context, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase`1.ExecuteBatchAsync(RetryableWriteContext context, Batch batch, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase`1.ExecuteBatchesAsync(RetryableWriteContext context, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteBatchAsync(RetryableWriteContext context, Batch batch, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;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, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;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 operation, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;at MongoDB.Driver.MongoCollectionImpl`1.BulkWriteAsync(IClientSessionHandle session, IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)&lt;br/&gt;
&#160; &#160;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)&lt;br/&gt;
&#160; &#160;at WebApi.Test.Unit.Controllers.MongoTestController.InsertManyElement() in G:\GitHub\EasilyNET\Test\WebApi.Test.Unit\Controllers\MongoTestController.cs:line 56&lt;br/&gt;
&#160; &#160;at lambda_method71(Closure, Object)&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&amp;lt;InvokeActionMethodAsync&amp;gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&amp;lt;InvokeNextActionFilterAsync&amp;gt;g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&amp;amp; next, Scope&amp;amp; scope, Object&amp;amp; state, Boolean&amp;amp; isCompleted)&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()&lt;br/&gt;
&amp;#8212; End of stack trace from previous location &amp;#8212;&lt;br/&gt;
&#160; &#160;at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&amp;lt;InvokeNextExceptionFilterAsync&amp;gt;g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)&lt;/p&gt;</description>
                <environment></environment>
        <key id="2290029">CSHARP-4570</key>
            <summary>dynamic type BsonSerializationException</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="boris.dogadov@mongodb.com">Boris Dogadov</assignee>
                                    <reporter username="dygood@outlook.com">&#23431; &#26460;</reporter>
                        <labels>
                            <label>Bug</label>
                    </labels>
                <created>Thu, 16 Mar 2023 16:04:07 +0000</created>
                <updated>Fri, 27 Oct 2023 13:24:38 +0000</updated>
                            <resolved>Tue, 28 Mar 2023 22:18:16 +0000</resolved>
                                    <version>2.19.0</version>
                                                    <component>Serialization</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5307760" author="JIRAUSER1257742" created="Tue, 28 Mar 2023 22:18:06 +0000"  >&lt;p&gt;Thanks for the update &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=dygood%40outlook.com&quot; class=&quot;user-hover&quot; rel=&quot;dygood@outlook.com&quot;&gt;dygood@outlook.com&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="5303519" author="JIRAUSER1272688" created="Mon, 27 Mar 2023 17:29:39 +0000"  >&lt;p&gt;&#128536; Thanks! &#160;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=boris.dogadov%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;boris.dogadov@mongodb.com&quot;&gt;boris.dogadov@mongodb.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It&apos;s working well so far.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="5303388" author="JIRAUSER1257742" created="Mon, 27 Mar 2023 16:59:36 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=dygood%40outlook.com&quot; class=&quot;user-hover&quot; rel=&quot;dygood@outlook.com&quot;&gt;dygood@outlook.com&lt;/a&gt;&#160;&lt;/p&gt;

&lt;p&gt;2.19 introduced a security fix (&lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-4475&quot; title=&quot;Add an AllowedTypes filter to ObjectSerializer&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-4475&quot;&gt;&lt;del&gt;CSHARP-4475&lt;/del&gt;&lt;/a&gt;) that requires any object serialization to specify the allowed types for serialization.&lt;br/&gt;
For allowing the default system types and anonymous types, please add this code to application startup:&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;
&lt;div class=&apos;table-wrap&apos;&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;var objectSerializer = new ObjectSerializer(type =&amp;gt; ObjectSerializer.DefaultAllowedTypes(type) &amp;#124;&amp;#124; type.FullName.StartsWith(&quot;&amp;lt;&amp;gt;f__AnonymousType&quot;));&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;BsonSerializer.RegisterSerializer(objectSerializer);&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;


&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Please note that this is a quick and informal way to validate whether the type is anonymous . There are other ways to check whether a type is an anonymous one.&lt;/p&gt;

&lt;p&gt;We&apos;ll be researching this further in&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/CSHARP-4534&quot; title=&quot;Consider adding anonymous types to DefaultAllowedTypes&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CSHARP-4534&quot;&gt;&lt;del&gt;CSHARP-4534&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="5279810" author="JIRAUSER1272688" created="Fri, 17 Mar 2023 05:08:23 +0000"  >&lt;p&gt;I looked at the changelog and found that the new version of the driver does not support dynamic types anymore, but my original code has some use of dynamic types, and many test examples have used them. I now want to support dynamic types myself, how should I do? Can you give me an example?&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_14266" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Documentation Changes Summary</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1.  What would you like to communicate to the user about this feature?&lt;br/&gt;
2.  Would you like the user to see examples of the syntax and/or executable code and its output?&lt;br/&gt;
3.  Which versions of the driver/connector does this apply to?&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i1iu1k:</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>