<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:49:26 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-4812] Improve docs or improve duplicate key error handling</title>
                <link>https://jira.mongodb.org/browse/CSHARP-4812</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;So when I first wrote my code for signing up a user, I had written this in case a user tried to sign up from two phones at the same time. The code is below&lt;/p&gt;

&lt;p&gt;&#160; &#160; &#160; &#160; try &lt;/p&gt;
{
&#160; &#160; &#160; &#160; &#160; &#160; await _usersCollection.InsertOneAsync(user);
&#160; &#160; &#160; &#160; &#160; &#160; return true;
&#160; &#160; &#160; &#160; }
&lt;p&gt; catch (MongoDuplicateKeyException) { return false; }&lt;/p&gt;

&lt;p&gt;Yesterday, I had to create a custom account for the mobile app reviewer so that they don&apos;t have to use their own email. The review failed. I wondered why today. I looked at the logs, ran the test myself, and at first it worked and then on subsequent tries it did not. I looked at the logs and saw duplicate key error. I saw my source code it was as seen above. I was confused. Miraculously, I found this on stack overflow so I was able to fix my code even though the fault was MongoDB for having an exception called DuplicateKeyException that doesn&apos;t actually catch a duplicate key exception.&lt;/p&gt;

&lt;p&gt;&#160; &#160; &#160; &#160; } catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey) &lt;/p&gt;
{
&#160; &#160; &#160; &#160; &#160; &#160; return false;
&#160; &#160; &#160; &#160; }

&lt;p&gt;I suggest that the following is documented as an example in the API docs or in the usage docs or better yet, I hope the driver is updated so that the code in the first block works because the second block is too verbose to know by heart.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2475253">CSHARP-4812</key>
            <summary>Improve docs or improve duplicate key error handling</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="oleksandr.poliakov@mongodb.com">Oleksandr Poliakov</assignee>
                                    <reporter username="elopez@splitthetank.com">Elijah Lopez</reporter>
                        <labels>
                    </labels>
                <created>Mon, 16 Oct 2023 14:11:36 +0000</created>
                <updated>Thu, 7 Dec 2023 00:32:26 +0000</updated>
                                                            <fixVersion>3.0.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="5931538" author="JIRAUSER1273473" created="Thu, 7 Dec 2023 00:32:17 +0000"  >&lt;p&gt;Sorry for the really late response.&lt;/p&gt;

&lt;p&gt;Thank you for reporting this non-intuitive behavior. I agree that exception handling ought to be reviewed, but we cannot do this just now as it will lead to a breaking change. We will include such review into upcoming v3 release where we planning to spend most of our time on API review and polishing.&lt;/p&gt;

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

&lt;p&gt;Thanks&lt;/p&gt;</comment>
                            <comment id="5781158" author="dbeng-pm-bot" created="Mon, 16 Oct 2023 14:11:39 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=elopez%40splitthetank.com&quot; class=&quot;user-hover&quot; rel=&quot;elopez@splitthetank.com&quot;&gt;elopez@splitthetank.com&lt;/a&gt;, thank you for reporting this issue! The team will look into it and get back to you soon. &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|i2e3j0:</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>