<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 22:01:44 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>[CXX-1197] Client and pool initialization should fail if no instance configured</title>
                <link>https://jira.mongodb.org/browse/CXX-1197</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;Programs that use mongocxx functionality without first creating a mongocxx::instance object are ill-formed.  We should attempt to detect this scenario, fail fast, and provide readable error messages to users, where possible.&lt;/p&gt;

&lt;p&gt;One approach to address this is to have the mongocxx::client and mongocxx::pool constructors fail if no instance is configured.  This will cover many ill-formed programs, but not all.&lt;/p&gt;</description>
                <environment></environment>
        <key id="347247">CXX-1197</key>
            <summary>Client and pool initialization should fail if no instance configured</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="rassi">J Rassi</reporter>
                        <labels>
                    </labels>
                <created>Fri, 20 Jan 2017 02:20:39 +0000</created>
                <updated>Thu, 31 Mar 2022 14:21:57 +0000</updated>
                                                                            <component>Implementation</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1567122" author="rassi@10gen.com" created="Mon, 8 May 2017 18:46:48 +0000"  >&lt;p&gt;See &lt;a href=&quot;http://stackoverflow.com/questions/43761382/cant-connect-to-mongodb-from-the-c-code&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://stackoverflow.com/questions/43761382/cant-connect-to-mongodb-from-the-c-code&lt;/a&gt; for an additional manifestation of failing to configure an instance.  This user encountered the error &quot;Failed to resolve &apos;127.0.0.1&apos;&quot; when attempting to perform a write.&lt;/p&gt;</comment>
                            <comment id="1480962" author="rassi@10gen.com" created="Fri, 20 Jan 2017 03:19:14 +0000"  >&lt;p&gt;I think this is somewhat of a different case of &quot;ensuring some objects exists for the duration of the use of another&quot; that deserves special attention, where I&apos;m seeing significant user pain and I think we can address it with minimal additional logic.  I&apos;d love to see us at least add some simple assertions to mongocxx::client and mongocxx::pool for 3.2, to help these users out before we release 4.0 (edit: though I do like your idea of making instance a client/pool factory for 4.0!).&lt;/p&gt;

&lt;p&gt;Currently, it&apos;s too easy for users to copy-paste code from elsewhere that issues database operations, and in the process fail to copy-paste the code that creates the mongocxx::instance object.  The symptoms of failing to create a mongocxx::instance are really non-obvious: the driver reports itself to the server as the C driver (since libmongoc::handshake_data_append(&quot;mongocxx&quot;, ...) is never called), and select driver functionality fails strangely due to mongoc_init() never being called.&lt;/p&gt;

&lt;p&gt;While it&apos;s true that users can accidentally use collection objects after destroying the database object that owns them, it&apos;s much more difficult to accidentally create a collection object without ever creating a database object in the first place.  However, per above, it&apos;s easy to accidentally create a client object without ever creating an instance object.  Because of this, I think users would appreciate us adding some basic sanity checks to client and pool.&lt;/p&gt;</comment>
                            <comment id="1480951" author="david.golden" created="Fri, 20 Jan 2017 02:55:06 +0000"  >&lt;p&gt;There are numerous places in the driver where users are responsible for ensuring some objects exists for the duration of the use of another.  I see this as a conceptually similar case and we can address it with better documentation.&lt;/p&gt;

&lt;p&gt;I&apos;d definitely prefer not to make an instance pointer required.  I&apos;d be more open to considering for a 4.0 release making instance into a client/pool factory and eliminating the public constructor for client/pool.&lt;/p&gt;</comment>
                            <comment id="1480942" author="rassi@10gen.com" created="Fri, 20 Jan 2017 02:21:48 +0000"  >&lt;p&gt;Alternatively, we could make a pointer to an instance object a required parameter for mongocxx::client and mongocxx::pool.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="347240">CXX-1196</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="355195">CXX-1224</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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hxk84v:</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>