<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:38:50 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>[GODRIVER-2530] Customer marshal method with pointer receiver not called for map values unless values are pointers</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2530</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;h4&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Given a container struct with a map and an entity struct with custom&lt;/em&gt; &lt;tt&gt;Marshaler&lt;/tt&gt;&#160;&lt;em&gt;and&lt;/em&gt; &lt;tt&gt;Unmarshaler&lt;/tt&gt; &lt;em&gt;methods. The custom methods are defined using pointer references to the entity struct.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If the map values in the container struct are pointers to the entity struct everything works fine. If the map values are the actual entity structs then the&lt;/em&gt; &lt;tt&gt;BSONMarshal&lt;/tt&gt;&#160;&lt;em&gt;method isn&apos;t called.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Array values seem to work just fine with both pointers and objects.&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;Pleaseprovidetheversionofthedriver.Ifapplicable%2CpleaseprovidetheMongoDBserverversionandtopology%28standalone%2Creplicaset%2Corshardedcluster%29.&quot;&gt;&lt;/a&gt;Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).&lt;/h4&gt;

&lt;p&gt;&lt;tt&gt;go.mongodb.org/mongo-driver v1.10.0&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;$ mongosh&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;Current Mongosh Log ID: &#160; &#160;6302b573833fe31f6ee26647&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;Connecting to: &#160; &#160; &#160; &#160;mongodb://127.0.0.1:27017/?directConnection=true&amp;amp;serverSelectionTimeoutMS=2000&amp;amp;appName=mongosh+1.5.4&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;Using MongoDB: &#160; &#160; &#160; &#160;6.0.1&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;Using Mongosh: &#160; &#160; &#160; &#160;1.5.4&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;$ go version&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;go version go1.18.5 linux/amd64&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;OS: Ubuntu 22.04.1 LTS x86_64&lt;/tt&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;HowtoReproduce&quot;&gt;&lt;/a&gt;How to Reproduce&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;See attached program&lt;/em&gt; &lt;tt&gt;bsonmap.go&lt;/tt&gt;&lt;em&gt;. Output I&apos;m getting:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;Ptr container:&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; MarshalBSON() &#160;&apos;listed&apos;-&amp;gt;1&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; MarshalBSON() &#160;&apos;mapped&apos;-&amp;gt;2&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; UnmarshalBSON() &#160;text listed|1&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; UnmarshalBSON() &#160;text mapped|2&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;! ptr == ptr2&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; ptr1: {&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;listed&amp;#39;-&amp;gt;1&amp;#93;&lt;/span&gt; map&lt;span class=&quot;error&quot;&gt;&amp;#91;ptrKey:&amp;#39;mapped&amp;#39;-&amp;gt;2&amp;#93;&lt;/span&gt;&lt;/tt&gt;}&lt;br/&gt;
&lt;tt&gt;&#160; ptr2: {&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;#39;listed&amp;#39;-&amp;gt;1&amp;#93;&lt;/span&gt; map&lt;span class=&quot;error&quot;&gt;&amp;#91;ptrKey:&amp;#39;mapped&amp;#39;-&amp;gt;2&amp;#93;&lt;/span&gt;&lt;/tt&gt;}&lt;br/&gt;
&lt;tt&gt;Obj container:&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; MarshalBSON() &#160;&apos;listed&apos;-&amp;gt;1&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; UnmarshalBSON() &#160;text listed|1&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; UnmarshalBSON() &#160;&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;Error unmarshaling objContainer: error decoding key index.objKey: wrong number of pieces: 1&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;* obj1 != obj2&lt;/tt&gt;&lt;br/&gt;
{{&#160; obj1: {[&lt;/p&gt;
{listed 1}] map&lt;span class=&quot;error&quot;&gt;&amp;#91;objKey:\{mapped 2}&amp;#93;&lt;/span&gt;}}}&lt;br/&gt;
{{&#160; obj2: {[{listed 1}
&lt;p&gt;] map[]}}}&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;AdditionalBackground&quot;&gt;&lt;/a&gt;Additional Background&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;In a more complex scenario (unable to provide this as a simple example at this time) I have seen the following message:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;couldn&apos;t read length from src, not enough bytes. length=0&lt;/tt&gt;{&lt;tt&gt;}&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is actual where I started trying to nail down the behavior. I suspect there is some relationship. This error only occurs when trying to use objects within maps, but&lt;/em&gt;&#160;not &lt;em&gt;in arrays, just like in the attached program.&lt;/em&gt;&lt;/p&gt;</description>
                <environment></environment>
        <key id="2118636">GODRIVER-2530</key>
            <summary>Customer marshal method with pointer receiver not called for map values unless values are pointers</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="preston.vasquez@mongodb.com">Preston Vasquez</assignee>
                                    <reporter username="mmadki@doorways.org">Marc Adkins</reporter>
                        <labels>
                    </labels>
                <created>Sun, 21 Aug 2022 22:54:33 +0000</created>
                <updated>Fri, 27 Oct 2023 13:16:22 +0000</updated>
                            <resolved>Tue, 23 Aug 2022 17:07:22 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4768903" author="JIRAUSER1270833" created="Mon, 22 Aug 2022 23:31:30 +0000"  >&lt;p&gt;I filed this same bug against &lt;tt&gt;encoding/json&lt;/tt&gt; and the answer is that &quot;map values are unaddressable&quot; whereas array values are addressable. This is apparently expected behavior.&lt;/p&gt;

&lt;p&gt;Confirmed (I guess) with &lt;a href=&quot;https://go.dev/play/p/RLjONtkgHP8&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://go.dev/play/p/RLjONtkgHP8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should close this bug.&lt;/p&gt;</comment>
                            <comment id="4767429" author="JIRAUSER1270833" created="Mon, 22 Aug 2022 15:33:43 +0000"  >&lt;p&gt;I have similar code using JSON and YAML. I went back to try and use objects instead of pointers there and neither works. YAML doesn&apos;t work at all and JSON seems to have the same behavior as this bug. I&apos;ll be digging in there for a bit and will update this bug if I find anything useful.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="4765886" author="JIRAUSER1270833" created="Sun, 21 Aug 2022 22:59:39 +0000"  >&lt;p&gt;&lt;em&gt;Something happened to my output text in the body of the issue. I&apos;ve attached it as an additonal text file&lt;/em&gt; &lt;tt&gt;output.txt&lt;/tt&gt;.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="397043" name="bsonmap.go" size="2702" author="mmadki@doorways.org" created="Sun, 21 Aug 2022 22:47:00 +0000"/>
                            <attachment id="397045" name="output.txt" size="529" author="mmadki@doorways.org" created="Sun, 21 Aug 2022 22:58:42 +0000"/>
                    </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|i0pwyw:</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>