<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:38:10 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-2252] Unmarshalling null into a pointer field always creates a value if the type implements bson.Unmarshaler or bson.ValueUnmarshaler</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2252</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;I&apos;m not sure, but have the feeling that the following code should not allocate an object for the field &quot;Baz&quot; and instead set it to nil: &lt;a href=&quot;https://go.dev/play/p/eRTWs2Y9sDe&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://go.dev/play/p/eRTWs2Y9sDe&lt;/a&gt;.&lt;/p&gt;

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

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

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1943437">GODRIVER-2252</key>
            <summary>Unmarshalling null into a pointer field always creates a value if the type implements bson.Unmarshaler or bson.ValueUnmarshaler</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="13201">Fixed</resolution>
                                        <assignee username="matt.dale@mongodb.com">Matt Dale</assignee>
                                    <reporter username="joel.gaehwiler@gmail.com">Jo&#235;l G&#228;hwiler</reporter>
                        <labels>
                    </labels>
                <created>Mon, 6 Dec 2021 18:56:00 +0000</created>
                <updated>Sat, 28 Oct 2023 11:37:40 +0000</updated>
                            <resolved>Wed, 2 Feb 2022 21:17:10 +0000</resolved>
                                                    <fixVersion>1.9.0</fixVersion>
                    <fixVersion>1.8.5</fixVersion>
                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4427800" author="xgen-internal-githook" created="Tue, 22 Mar 2022 19:07:46 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Matt Dale&apos;, &apos;email&apos;: &apos;9760375+matthewdale@users.noreply.github.com&apos;, &apos;username&apos;: &apos;matthewdale&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2252&quot; title=&quot;Unmarshalling null into a pointer field always creates a value if the type implements bson.Unmarshaler or bson.ValueUnmarshaler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2252&quot;&gt;&lt;del&gt;GODRIVER-2252&lt;/del&gt;&lt;/a&gt; Don&apos;t call UnmarshalBSON for pointer values if the BSON field value is empty. (#833)&lt;br/&gt;
Branch: release/1.8&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/e84d9eeb9b185ea0761d9396cdfb8889abe44bb4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/e84d9eeb9b185ea0761d9396cdfb8889abe44bb4&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4331707" author="JIRAUSER1259527" created="Wed, 2 Feb 2022 21:16:41 +0000"  >&lt;p&gt;Hey &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=joel.gaehwiler%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;joel.gaehwiler@gmail.com&quot;&gt;joel.gaehwiler@gmail.com&lt;/a&gt;, the PR was merged and is scheduled for release with the next minor version (v1.9.0). There&apos;s no scheduled date for the v1.9.0 driver release, but it will likely be in the next month. I&apos;m closing this ticket since the issue will be resolved in the next release. Please comment here again if you continue to have issues. Thanks!&lt;/p&gt;</comment>
                            <comment id="4291220" author="xgen-internal-githook" created="Thu, 13 Jan 2022 16:58:31 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Matt Dale&apos;, &apos;email&apos;: &apos;9760375+matthewdale@users.noreply.github.com&apos;, &apos;username&apos;: &apos;matthewdale&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-2252&quot; title=&quot;Unmarshalling null into a pointer field always creates a value if the type implements bson.Unmarshaler or bson.ValueUnmarshaler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-2252&quot;&gt;&lt;del&gt;GODRIVER-2252&lt;/del&gt;&lt;/a&gt; Don&apos;t call UnmarshalBSON for pointer values if the BSON field value is empty. (#833)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/c918d8c25286cf5ba0b7311b7d9c5c41e65bdd08&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/c918d8c25286cf5ba0b7311b7d9c5c41e65bdd08&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4287066" author="joel.gaehwiler@gmail.com" created="Tue, 11 Jan 2022 22:35:24 +0000"  >&lt;p&gt;Thanks for the update and I&apos;m looking forward to the PR being merged!&lt;/p&gt;</comment>
                            <comment id="4284864" author="JIRAUSER1259527" created="Tue, 11 Jan 2022 04:50:52 +0000"  >&lt;p&gt;Hey &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=joel.gaehwiler%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;joel.gaehwiler@gmail.com&quot;&gt;joel.gaehwiler@gmail.com&lt;/a&gt;, thanks for the feedback! We&apos;re currently reviewing a change to skip allocating a value and skip calling &lt;tt&gt;UnmarshalBSON&lt;/tt&gt; in the case where the receiver is a pointer and the corresponding BSON field value is empty (check it out &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/pull/833&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;</comment>
                            <comment id="4261608" author="joel.gaehwiler@gmail.com" created="Tue, 21 Dec 2021 14:29:30 +0000"  >&lt;p&gt;Thanks for your detailed investigation! I was actually stumbling over this issue while implementing a custom type in a library. The &quot;omitempty&quot; hack certainly works for prototyping the functionality, but the correct behaviour of setting the pointer to nil if there is a null value would be most welcome from a user perspective.&lt;/p&gt;

&lt;p&gt;If changing the behaviour ist not an option I could image that adding a sentinel error like &quot;ErrSetNil&quot; may be returned from the unmarshaling function to force a nil value? Perhaps, this might even open other use cases where a non-null value is unmarshalled, but the custom unmarshalling function would like to set a nil pointer.&lt;/p&gt;</comment>
                            <comment id="4260831" author="JIRAUSER1259527" created="Mon, 20 Dec 2021 23:41:08 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=joel.gaehwiler%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;joel.gaehwiler@gmail.com&quot;&gt;joel.gaehwiler@gmail.com&lt;/a&gt; thank you for the example code, it was really helpful to reproduce the behavior! The unexpected behavior is an inconsistency between how the BSON unmarshaler works and how the &lt;tt&gt;&quot;encoding/json&quot;&lt;/tt&gt; unmarshaler works when the destination field is a pointer, has a custom unmarshal function, and the associated value in the marshalled document is &lt;tt&gt;null&lt;/tt&gt;/empty. The &lt;tt&gt;&quot;encoding/json&quot;&lt;/tt&gt; unmarshaler doesn&apos;t allocate a value or call &lt;tt&gt;UnmarshalJSON&lt;/tt&gt; in that case (check out this helpful &lt;a href=&quot;https://stackoverflow.com/a/34163626/855419&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Stackoverflow answer&lt;/a&gt; for more context on why). However, the BSON unmarshaler does allocate a value and call &lt;tt&gt;UnmarshalBSON&lt;/tt&gt; in that case. I&apos;m currently investigating if making the BSON unmarshaler match the &lt;tt&gt;&quot;encoding/json&quot;&lt;/tt&gt; unmarshaler behavior makes sense and is safe (i.e. won&apos;t break any existing use cases).&lt;/p&gt;

&lt;p&gt;A short-term fix is to add the &lt;tt&gt;omitempty&lt;/tt&gt; directive to the struct tag to instruct the BSON marshaler to omit those empty fields from the output document. If the field is not included in the BSON document, the BSON unmarshaler for that field won&apos;t be called and no value will be allocated.&lt;/p&gt;

&lt;p&gt;E.g. &lt;tt&gt;foo&lt;/tt&gt; with &lt;tt&gt;omitempty&lt;/tt&gt;&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;type foo struct {&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;	Bar *bar `bson:&quot;,omitempty&quot;`&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;	Baz *baz `bson:&quot;,omitempty&quot;`&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;Does that fix resolve your issue or are there already-encoded documents that you need to read?&lt;/p&gt;</comment>
                            <comment id="4234875" author="esha.bhargava" created="Tue, 7 Dec 2021 16:52:40 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=joel.gaehwiler%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;joel.gaehwiler@gmail.com&quot;&gt;joel.gaehwiler@gmail.com&lt;/a&gt; Thank you for reporting this issue! We&apos;ll look into it and get back to you soon.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="2050021">GODRIVER-2427</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </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|hzwo7j:</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>