<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:33:57 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-317] Handle nil properties of a struct in the BSON encoder</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-317</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;The BSON encoder does not handle struct properties that can be nil. If it does encounter a nil struct property it returns an error when it should encode that value into a BSON Null.&lt;/p&gt;

&lt;p&gt;To fix this:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Update underlyingVal to check if the value is nil when it&apos;s Kind is either a reflect.Ptr or a reflect.Interface. If it is, don&apos;t return the underlying Elem, instead return the pointer or interface.&lt;/li&gt;
	&lt;li&gt;In encodeMap, encodeSlice, encodeSliceAsArray, and encodeStruct, after calling underlyingVal, if the kind is an interface, map, pointer, or slice, and it is nil, return a BSON Null type.&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="517504">GODRIVER-317</key>
            <summary>Handle nil properties of a struct in the BSON encoder</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="kris.brandow@mongodb.com">Kristofer Brandow</reporter>
                        <labels>
                    </labels>
                <created>Tue, 27 Mar 2018 18:08:04 +0000</created>
                <updated>Mon, 1 Oct 2018 21:21:53 +0000</updated>
                            <resolved>Thu, 5 Apr 2018 15:27:58 +0000</resolved>
                                    <version>0.0.2</version>
                                    <fixVersion>0.0.3</fixVersion>
                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="2019847" author="tdterry" created="Mon, 1 Oct 2018 21:21:53 +0000"  >&lt;p&gt;This is still an issue with the StructCodec when trying to encode a struct that has a field which is a pointer to another struct. If the pointer is nil, it fails to encode here &lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/blob/master/bson/bsoncodec/struct_codec.go#L50&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/blob/master/bson/bsoncodec/struct_codec.go#L50&lt;/a&gt;. That needs a val.IsNil() check.&lt;/p&gt;

&lt;p&gt;Also, it took me a long time to track this down. I see that you return an error that the encoder &quot;can only process structs,&quot; but that error is later replaced by a more generic error &quot;failed to encode.&quot; Returning the more specific error would have made this a lot easier to find.&lt;/p&gt;

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

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1856352" author="xgen-internal-githook" created="Thu, 5 Apr 2018 15:23:44 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;kris@mongodb.com&apos;, &apos;name&apos;: &apos;Kris Brandow&apos;, &apos;username&apos;: &apos;skriptble&apos;}
&lt;p&gt;Message: Handle nil properly in BSON encoder&lt;/p&gt;

&lt;p&gt;Added support for nil interfaces, maps, pointers, and slices.&lt;br/&gt;
Added support for round tripping empty maps and slices and nil maps and&lt;br/&gt;
slices. Since these are distinct in Go, we use BSON Null for a nil map&lt;br/&gt;
or slice and an empty document or array, respectively, for zero value&lt;br/&gt;
map and slice types.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-317&quot; title=&quot;Handle nil properties of a struct in the BSON encoder&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-317&quot;&gt;&lt;del&gt;GODRIVER-317&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;https://jira.mongodb.org/browse/GODRIVER-315&quot; title=&quot;Mongo shipped BSON marshaller to support nested structs using embedding&quot; class=&quot;issue-link&quot; data-issue-key=&quot;GODRIVER-315&quot;&gt;&lt;del&gt;GODRIVER-315&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Change-Id: I96036138acb745b1f42d3190e9664366bb85a9a6&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-go-driver/commit/bf482478e9fde8a815ce22eec54a36c0ab410502&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-go-driver/commit/bf482478e9fde8a815ce22eec54a36c0ab410502&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1854428" author="kris.brandow" created="Tue, 3 Apr 2018 21:58:36 +0000"  >&lt;p&gt;Code Review: &lt;a href=&quot;https://review.gerrithub.io/c/406250/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.gerrithub.io/c/406250/&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="1846798" author="kris.brandow" created="Tue, 27 Mar 2018 18:12:45 +0000"  >&lt;p&gt;This bug will cause problems with some of our internal types that use pointers if we ever try to marshal them, so scheduling this.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="517214">GODRIVER-315</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="517214">GODRIVER-315</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>GODRIVER-271</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htkztj:</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>