You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/12/09 05:45:34 UTC
[GitHub] [lucene-solr] munendrasn commented on a change in pull request #2121: SOLR-10860: Return proper error code for bad input incase of inplace updates
munendrasn commented on a change in pull request #2121:
URL: https://github.com/apache/lucene-solr/pull/2121#discussion_r539024109
##########
File path: solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesStandalone.java
##########
@@ -121,6 +123,36 @@ public void deleteAllAndCommit() throws Exception {
assertU(commit("softCommit", "false"));
}
+ @Test
+ public void testUpdateBadRequest() throws Exception {
+ final long version1 = addAndGetVersion(sdoc("id", "1", "title_s", "first", "inplace_updatable_float", 41), null);
+ assertU(commit());
+
+ // invalid value with set operation
+ SolrException e = expectThrows(SolrException.class,
+ () -> addAndAssertVersion(version1, "id", "1", "inplace_updatable_float", map("set", "NOT_NUMBER")));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ MatcherAssert.assertThat(e.getMessage(), containsString("For input string: \"NOT_NUMBER\""));
+
+ // invalid value with inc operation
+ e = expectThrows(SolrException.class,
+ () -> addAndAssertVersion(version1, "id", "1", "inplace_updatable_float", map("inc", "NOT_NUMBER")));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ MatcherAssert.assertThat(e.getMessage(), containsString("For input string: \"NOT_NUMBER\""));
+
+ // inc op with null value
+ e = expectThrows(SolrException.class,
+ () -> addAndAssertVersion(version1, "id", "1", "inplace_updatable_float", map("inc", null)));
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ MatcherAssert.assertThat(e.getMessage(), containsString("Invalid input 'null' for field inplace_updatable_float"));
+
+ e = expectThrows(SolrException.class,
+ () -> addAndAssertVersion(version1, "id", "1", "inplace_updatable_float",
Review comment:
We can increment float by an integer. In this particular test input, verifying the case when instead of passing the number, a list of numbers is passed. Previously, Solr used to return 500 with the current changes Bad request would be returned
`"Invalid input '[123]' for field inplace_updatable_float"`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org