<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:38:19 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-966] Saving a dynamic value causes stackoverflow</title>
                <link>https://jira.mongodb.org/browse/CSHARP-966</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I have a model that has a attribute like:&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;   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;     public Dictionary&amp;lt;string, dynamic&amp;gt; Values { get; set; }&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;the Values attribute typically accepts objects like:&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;[ &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;	    { &quot;24352435234&quot;: 2343 }   // Number&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;	    { &quot;24352435234&quot;: &quot;Henry&quot; } // Text&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;	    { &quot;24352435234&quot;: DateTime }  // Date&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;	    { &quot;23452435234&quot;: &quot;23452345243&quot; } // Single select box&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;	    { &quot;23452435234&quot;: [&quot;23452345243&quot;, &quot;2345234234&quot;] } // Multi-select box ---- this doesn&apos;t work currently&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;	    { &quot;23452435234&quot;: &quot;SW-132&quot; } // Id&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;all works fine until I do the Multi-Select case and then it does a stackoverflow and totally kills the .net process.  Heres a quick video of the post/fail/errors &lt;a href=&quot;http://www.screencast.com/t/MQG7hdvOcr&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.screencast.com/t/MQG7hdvOcr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using 1.9 driver, it saves fine but on de-serialization it fails.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Note: I&apos;m using the nightly 3.0.0-build-0052 *&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="135312">CSHARP-966</key>
            <summary>Saving a dynamic value causes stackoverflow</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="amcdnl">Austin McDaniel</reporter>
                        <labels>
                    </labels>
                <created>Wed, 7 May 2014 14:14:12 +0000</created>
                <updated>Sat, 4 Apr 2015 22:50:54 +0000</updated>
                            <resolved>Sat, 4 Apr 2015 22:50:54 +0000</resolved>
                                    <version>2.0</version>
                                                    <component>Serialization</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="583866" author="craiggwilson" created="Wed, 14 May 2014 17:46:46 +0000"  >&lt;p&gt;Brant,&lt;br/&gt;
  It serializes type information because, when using dynamic, that gets translated to object at runtime.  Hence, we need to be able to read the data back in and therefore put some type information in there.  In the 3.0.0 branch, instead of having the JsonConverter change it to a string[], have it change it to a List&amp;lt;object&amp;gt;.  This is the currently recognized type for persisting arrays without type information. When it comes back, it will come back as a List&amp;lt;object&amp;gt;.  Again, at compile time, this would be List&amp;lt;dynamic&amp;gt; to you, so the underlying List&amp;lt;object&amp;gt; is somewhat hidden.  We are trying to balance the support for dynamic with the need to support round-trip fidelity of information.&lt;/p&gt;

&lt;p&gt;Craig&lt;/p&gt;</comment>
                            <comment id="583691" author="brantw" created="Wed, 14 May 2014 16:01:08 +0000"  >&lt;p&gt;We ended up working around this by creating a Json converter to convert the type from a JArray to a string[] before sending the data to Mongo, like this: &lt;a href=&quot;https://gist.github.com/brantw/02cedc0c6ece275552da&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/brantw/02cedc0c6ece275552da&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The only oddity with this approach is that the C# driver will add some type metadata when saving to Mongo that the array type is System.String[], but everything serializes without error.&lt;/p&gt;

&lt;p&gt;It would be awesome if the Mongo driver handled Json.NET types automatically since Json.NET has become the de-facto standard for Json serialization in the .NET world.&lt;/p&gt;</comment>
                            <comment id="581484" author="rstam" created="Tue, 13 May 2014 00:02:52 +0000"  >&lt;p&gt;Oh.... the Json.NET classes don&apos;t serialize well with the BsonClassMapSerializer (we document the assumptions that BsonClassMapSerializer makes about classes that it is able to serialize automatically, and some of the Json.NET classes don&apos;t meet our requirements).&lt;/p&gt;

&lt;p&gt;The stack overflow is actually related to JToken. Note that JToken is defined in Json.NET as:&lt;/p&gt;

&lt;p&gt;public abstract class JToken : IEnumerable&amp;lt;JToken&amp;gt; ...&lt;/p&gt;

&lt;p&gt;When we try to find a suitable serializer for JToken, we see that it implements IEnumerable&amp;lt;T&amp;gt;, so we conclude that we should serialize it as an array and we recursively look up the serializer for &amp;lt;T&amp;gt;, but since &amp;lt;T&amp;gt; happens to be JToken we end up with a stack overflow.&lt;/p&gt;

&lt;p&gt;I don&apos;t know what it would take to succesfully serialize the full suite of Json.NET data objects to MongoDB, but it would require writing multiple custom serializers that work with the Json.NET data types.&lt;/p&gt;</comment>
                            <comment id="581412" author="brantw" created="Mon, 12 May 2014 22:58:12 +0000"  >&lt;p&gt;Hi Robert,&lt;/p&gt;

&lt;p&gt;Please see &lt;a href=&quot;https://github.com/brantw/mongo-csharp-driver/commit/9885eb02e2bbf386b6850cca875c9254c898365d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/brantw/mongo-csharp-driver/commit/9885eb02e2bbf386b6850cca875c9254c898365d&lt;/a&gt; for an example of a failing test.&lt;/p&gt;

&lt;p&gt;The stack overflow seems to be generated when serializing the Json.NET JArray class.&lt;/p&gt;</comment>
                            <comment id="575861" author="rstam" created="Wed, 7 May 2014 18:42:05 +0000"  >&lt;p&gt;Thanks for reporting this. I am attempting to reproduce this, but am so far unable to.&lt;/p&gt;

&lt;p&gt;Can you isolate this to a small sample class definition and a sample JSON document that fails to deserialize?&lt;/p&gt;

&lt;p&gt;You can see my attempts so far to reproduce here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/rstam/mongo-csharp-driver/tree/csharp966&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/rstam/mongo-csharp-driver/tree/csharp966&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here&apos;s a direct URL to the file with the tests:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/rstam/mongo-csharp-driver/blob/csharp966/src/MongoDB.Bson.Tests/Jira/CSharp966Tests.cs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/rstam/mongo-csharp-driver/blob/csharp966/src/MongoDB.Bson.Tests/Jira/CSharp966Tests.cs&lt;/a&gt;&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|hrfdlb:</customfieldvalue>

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