<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:56:22 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>[JAVA-2114] Better error message for &quot;Invalid BSON field name&quot;</title>
                <link>https://jira.mongodb.org/browse/JAVA-2114</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I&apos;m getting java.lang.IllegalArgumentException: &quot;Invalid BSON field name&quot; for update operation.&lt;/p&gt;</description>
                <environment></environment>
        <key id="264689">JAVA-2114</key>
            <summary>Better error message for &quot;Invalid BSON field name&quot;</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="aleksey.korolev">Aleksey Korolev</reporter>
                        <labels>
                    </labels>
                <created>Thu, 11 Feb 2016 13:21:25 +0000</created>
                <updated>Tue, 26 Jul 2022 15:39:58 +0000</updated>
                            <resolved>Tue, 26 Jul 2022 15:39:58 +0000</resolved>
                                    <version>3.2.0</version>
                                    <fixVersion>4.8.0</fixVersion>
                                    <component>Error Handling</component>
                                        <votes>4</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="4705795" author="xgen-internal-githook" created="Tue, 26 Jul 2022 15:39:34 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;email&apos;: &apos;jeff.yemin@mongodb.com&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: Improve error message for invalid field names (#985)&lt;/p&gt;

&lt;p&gt;For replacement documents, it&apos;s now:&lt;br/&gt;
  &quot;Field names in a replacement document can not start with &apos;$&apos; but &apos;%s&apos; does&quot;&lt;br/&gt;
For update documents, it&apos;s now:&lt;br/&gt;
  &quot;All update operators must start with &apos;$&apos;, but &apos;%s&apos; does not&quot;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2114&quot; title=&quot;Better error message for &amp;quot;Invalid BSON field name&amp;quot;&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2114&quot;&gt;&lt;del&gt;JAVA-2114&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/6693493aab3ec178feb2470aac1190b52d39e7e7&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/6693493aab3ec178feb2470aac1190b52d39e7e7&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2192717" author="jeff.yemin" created="Wed, 27 Mar 2019 01:22:14 +0000"  >&lt;p&gt;There is an undeprecated variant of replaceOne: &lt;tt&gt;replaceOne(Bson filter, TDocument replacement, ReplaceOptions replaceOptions)&lt;/tt&gt;&lt;/p&gt;</comment>
                            <comment id="2192712" author="peter.williamson" created="Wed, 27 Mar 2019 01:18:29 +0000"  >&lt;p&gt;Using replaceOne is a viable alternative if you want to replace the whole document, but it&apos;s marked as deprecated in the 3.7 driver. So this bug should be fixed or replaceOne reinstated.&#160;&lt;/p&gt;</comment>
                            <comment id="2192704" author="peter.williamson" created="Wed, 27 Mar 2019 00:52:34 +0000"  >&lt;p&gt;IMHO this is incorrect validation. In the mongo client you can update without needing $set, db.collection.update( { _id: key}, { _id: key, field: value } ) works fine, but fails in the java driver with the &quot;Invalid BSON field name _id&quot;&#160; exception.&#160; The same error occurs with upsert=true and having to use $set with an upsert makes no sense.&#160;&lt;/p&gt;</comment>
                            <comment id="1822596" author="mjwinters" created="Sun, 4 Mar 2018 21:45:09 +0000"  >&lt;p&gt;here&apos;s a PR &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/pull/460&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/pull/460&lt;/a&gt;. &lt;br/&gt;
I also cloned this issue on accident ( &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2798&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/JAVA-2798&lt;/a&gt; ) sorry about that &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/sad.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="1650081" author="nmayakuntla" created="Wed, 16 Aug 2017 23:36:32 +0000"  >&lt;p&gt;Any update on this?&lt;/p&gt;</comment>
                            <comment id="1170788" author="jeff.yemin" created="Thu, 11 Feb 2016 17:05:07 +0000"  >&lt;p&gt;OK, I see now. Thanks for reporting this.  We&apos;ll see what we can do in a future release to address this.&lt;/p&gt;</comment>
                            <comment id="1170778" author="aleksey.korolev" created="Thu, 11 Feb 2016 16:56:26 +0000"  >&lt;p&gt;Sorry for not giving enough detail.&lt;br/&gt;
My error happened during collection.update(...) call after UpdateFieldNameValidator checked that field name doesn&apos;t start with $.&lt;br/&gt;
I reproduced error one more time and it indeed gave me field name: &lt;br/&gt;
java.lang.IllegalArgumentException: Invalid BSON field name customerID&lt;br/&gt;
Probably I overlooked it 1st time.&lt;br/&gt;
But it would be nice to have each validator provide details on what exactly it doesn&apos;t like about the field.&lt;br/&gt;
For example in this particular case I didn&apos;t know MongoDB update semantics good enough to quickly undersand the reason before I dug into code.&lt;br/&gt;
A resulting message like &lt;br/&gt;
&quot;Invalid BSON field name customerID. Missing $ name prefix.&quot;&lt;br/&gt;
would be nice.&lt;/p&gt;</comment>
                            <comment id="1170533" author="jeff.yemin" created="Thu, 11 Feb 2016 13:30:12 +0000"  >&lt;p&gt;Looks like the message is generated from &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/3.2.x/bson/src/main/org/bson/AbstractBsonWriter.java#L494&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;, which does include the field name.  &lt;/p&gt;

&lt;p&gt;Can you provide the full stack trace?&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|hsiapz:</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>