<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:37:51 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-2116] Add MongoDB Error Codes as Constants</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-2116</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;MongoDB has a list of error codes here: &lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml#L36&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.yml#L36&lt;/a&gt;. I think it would be helpful to have these error codes exposed as constants so that when handling `ServerErrors` when using the Go Driver, those constants can be used to handle specific errors. Otherwise, code that uses the go driver needs to copy + paste the error codes manually which can be error prone or might become out of sync. In addition, non-MongoDB employees might not easily know where to find these error codes.&lt;/p&gt;

&lt;p&gt;This came up during some work on index migration as part of Realm Sync but I think this would be beneficial to users of the Go Driver in general.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1842357">GODRIVER-2116</key>
            <summary>Add MongoDB Error Codes as Constants</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="11262" iconUrl="https://jira.mongodb.org/images/icons/statuses/generic.png" description="">Investigating</status>
                    <statusCategory id="4" key="indeterminate" colorName="inprogress"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="matt.dale@mongodb.com">Matt Dale</assignee>
                                    <reporter username="rushil.kumar@mongodb.com">Rushil Kumar</reporter>
                        <labels>
                    </labels>
                <created>Thu, 5 Aug 2021 15:22:05 +0000</created>
                <updated>Fri, 15 Dec 2023 18:38:43 +0000</updated>
                                                                                                <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="5954241" author="JIRAUSER1259527" created="Fri, 15 Dec 2023 18:38:43 +0000"  >&lt;p&gt;Yes I did, good catch! I&apos;ve updated that comment.&lt;/p&gt;</comment>
                            <comment id="5945781" author="rushil.kumar" created="Tue, 12 Dec 2023 21:10:56 +0000"  >&lt;p&gt;I believe the link you included in your previous comment refers to the list of error codes in the BAAS repo, did you mean to link to something else? And yes, I agree, exposing some of the labels and error codes are consts would be helpful. Do you think this ticket would be good to capture that work?&lt;/p&gt;</comment>
                            <comment id="5918928" author="JIRAUSER1259527" created="Fri, 1 Dec 2023 18:15:19 +0000"  >&lt;p&gt;There is now public documentation of common error codes: &lt;a href=&quot;https://www.mongodb.com/docs/manual/reference/error-codes/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://www.mongodb.com/docs/manual/reference/error-codes/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I&apos;m still concerned about the usability of comparing error codes in application logic because that requires deeper understanding of exactly what the error means and what related errors should be treated the same. For those reasons, we should generally discourage users from writing application logic that compares error codes directly (error codes should only be used to understand specifically what happened). Instead, we should encourage users to write application logic that compares error &lt;em&gt;labels&lt;/em&gt;, which describes the class of error (e.g. bad input, bad database state, timeout, etc) and will result in more resilient application logic that continues to work as additional error codes are added.&lt;/p&gt;

&lt;p&gt;&#160;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=rushil.kumar%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;rushil.kumar@mongodb.com&quot;&gt;rushil.kumar@mongodb.com&lt;/a&gt; can you share more details about your specific use cases for error code constants in application logic? Could you use error labels instead of error codes for your use case?&lt;/p&gt;</comment>
                            <comment id="3996245" author="benji.rewis" created="Wed, 11 Aug 2021 21:18:33 +0000"  >&lt;p&gt;Thanks for your improvement suggestion &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=rushil.kumar&quot; class=&quot;user-hover&quot; rel=&quot;rushil.kumar&quot;&gt;rushil.kumar&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;For context, drivers treat error labels from the server as the most reliable form of error identification and categorization. Error messages are subject to change and should therefore not be relied upon in error handling logic. Error codes are somewhere in between: they have been subject to change in the past and, while more stable than messages, are not exhaustively defined anywhere.&lt;/p&gt;

&lt;p&gt;At this point in time, we do not feel comfortable exposing error code constants as public API. Because of their apparent malleability, error code constants could introduce the potential for breaking API changes in the future. Furthermore, we&#8217;d like to encourage users to use error labels because of their relative reliability instead of error codes. Finally, the Go driver team would have to maintain these constants to make sure we do not fall out of sync with the server. From a quick poll, it seems that other drivers also do not expose error code constants for the above reasons.&lt;/p&gt;

&lt;p&gt;There is an open DOCS ticket I&#8217;ve linked to this one that describes the task of generating documentation for every error code in the server. This is not an easy task, as new error codes are always being added and even &lt;tt&gt;error_codes.yml&lt;/tt&gt;&#160;only represents a subset of the codes. Once the server exposes some firm documentation on MongoDB error codes, we could reconsider adding our own constants.&lt;/p&gt;

&lt;p&gt;Let me know if you need any other help with error handling as part of your index migration project.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="423832">DOCS-10757</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|hzggdb:</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>