You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2026/05/06 04:12:02 UTC

Re: [PR] SOLR-18175: Return BAD_REQUEST for FieldExistsQuery IllegalStateException [solr]

dsmiley commented on code in PR #4369:
URL: https://github.com/apache/solr/pull/4369#discussion_r3192929931


##########
solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java:
##########
@@ -133,6 +133,7 @@
  */
 public class QueryComponent extends SearchComponent {
   public static final String COMPONENT_NAME = "query";
+  private static final String FIELD_EXISTS_QUERY_REQUIRES_PREFIX = "FieldExistsQuery requires";

Review Comment:
   just inline this please; the constant isn't useful



##########
solr/core/src/test/org/apache/solr/handler/component/QueryComponentFieldExistsQueryErrorHandlingTest.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.handler.component;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.search.QueryCommand;
+import org.apache.solr.search.SolrIndexSearcher;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class QueryComponentFieldExistsQueryErrorHandlingTest extends SolrTestCaseJ4 {

Review Comment:
   I don't trust Mocking to reflect the real world we want, not to mention it can be rather invasive as this test shows.  And invasiveness leads to a bigger maintenance burden over time.  Can you not provoke the problem as reported in a realistic test?  I can try to help if needed or we just provoke it in a manual way and not even have an automated test.  It's questionable if the problem is worth an extensive test.



##########
solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java:
##########
@@ -435,6 +436,9 @@ public void process(ResponseBuilder rb) throws IOException {
         }
       } catch (SyntaxError e) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
+      } catch (IllegalStateException e) {
+        maybeThrowBadRequestForFieldExistsQueryFailure(e);
+        throw e;

Review Comment:
   copilot is rightfully suspicious.



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org