<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:39:17 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-2751] Make all BSON-to-Go numeric type conversions safe</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2751</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;There are currently cases where the existing &lt;tt&gt;bson.RawValue&lt;/tt&gt; &lt;tt&gt;As*&lt;/tt&gt; conversion methods (i.e. methods that convert between numeric representations, not just unmarshal from BSON to Go values) will silently lose data. Additionally, there is currently no way to convert a &lt;tt&gt;bson.RawValue&lt;/tt&gt; holding a BSON numeric value into Go &lt;tt&gt;float64&lt;/tt&gt; value.&lt;/p&gt;

&lt;p&gt;Safe conversion between int and float type values is available via &lt;tt&gt;bson.Unmarshal&lt;/tt&gt;. The numeric conversion behavior of &lt;tt&gt;bson.Unmarshal&lt;/tt&gt; matches &lt;tt&gt;json.Unmarshal&lt;/tt&gt;. Note that JSON represents numbers as arbitrary precision unquoted strings, which always require parsing, but BSON numeric values use the same types as Go numeric values and can be directly converted without parsing. The only lossy case that is supported by both &lt;tt&gt;bson.Unmarshal&lt;/tt&gt; and &lt;tt&gt;json.Unmarshal&lt;/tt&gt; is conversion of integer values greater than 2^53 to &lt;tt&gt;float64&lt;/tt&gt;, which retains the approximate magnitude but loses exact integer precision. Check out an example of numeric conversion on the Go Playground &lt;a href=&quot;https://go.dev/play/p/lhajvEGJFn4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Definition of done:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Update &lt;tt&gt;AsInt64&lt;/tt&gt;/&lt;tt&gt;AsInt64OK&lt;/tt&gt; to match the behavior of &lt;tt&gt;bson.Unmarshal&lt;/tt&gt;. That means panic/return &lt;tt&gt;ok=false&lt;/tt&gt; on any lossy BSON &quot;double&quot; to Go &lt;tt&gt;int64&lt;/tt&gt; conversions. Unsafe-to-convert &quot;double&quot; values are:
	&lt;ul&gt;
		&lt;li&gt;Any value with a fractional part (truncates the fractional part)&lt;/li&gt;
		&lt;li&gt;Greater than math.MaxInt64 (returns math.MinInt64)&lt;/li&gt;
		&lt;li&gt;Less than math.MinInt64 (returns math.MinInt64)&lt;/li&gt;
		&lt;li&gt;NaN, +Inf, -Inf&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Add &lt;tt&gt;AsFloat64&lt;/tt&gt; and &lt;tt&gt;AsFloat64OK&lt;/tt&gt; functions that convert any BSON numeric value to a Go &lt;tt&gt;float64&lt;/tt&gt;. Those functions should have the same conversion behavior as &lt;tt&gt;bson.Unmarshal&lt;/tt&gt;.&lt;/li&gt;
	&lt;li&gt;Consider updating &lt;tt&gt;bson.Unmarshal&lt;/tt&gt; and &lt;tt&gt;AsFloat64&lt;/tt&gt;/&lt;tt&gt;AsFloat64OK&lt;/tt&gt; to fail if there is a loss of precision when converting &lt;tt&gt;int64&lt;/tt&gt; values to &lt;tt&gt;float64&lt;/tt&gt; values. Lossy values are:
	&lt;ul&gt;
		&lt;li&gt;Greater than 2^53 (loses integer precision)&lt;/li&gt;
		&lt;li&gt;Less than -1 * 2^53 (loses integer precision)&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="2256117">GODRIVER-2751</key>
            <summary>Make all BSON-to-Go numeric type conversions safe</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="matt.dale@mongodb.com">Matt Dale</reporter>
                        <labels>
                    </labels>
                <created>Wed, 8 Feb 2023 00:10:45 +0000</created>
                <updated>Mon, 8 Jan 2024 21:09:04 +0000</updated>
                                                            <fixVersion>2.0.0</fixVersion>
                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1887367">GODRIVER-2167</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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>GODRIVER-2973</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_21553" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Quarter</customfieldname>
                        <customfieldvalues>
                                        <label>FY24Q3</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr6jqv:s0000yz6</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>