Re: [PR] SOLR-18482: Reject unsupported parameters on JSON range facets [solr]

2026-10-05 Thread via GitHub


nick-boss-tech commented on code in PR #5009:
URL: https://github.com/apache/solr/pull/5009#discussion_r4190185268


##
solr/solr-ref-guide/modules/query-guide/pages/json-facet-api.adoc:
##
@@ -407,6 +407,10 @@ By default, the ranges used to compute range faceting 
between `start` and `end`
 Refer <>
 |===
 
+The range facet does not support the `limit`, `offset`, `sort`, `prelim_sort`, 
`overrequest`, `overrefine`, or `refine` parameters that terms facets accept.
+Using any of them in a range facet is rejected with a 400 error naming the 
parameter.

Review Comment:
   Done, removed in 49ca9099d8e.



##
solr/core/src/java/org/apache/solr/search/facet/FacetRangeParser.java:
##
@@ -23,6 +23,13 @@
 import org.apache.solr.search.SyntaxError;
 
 class FacetRangeParser extends FacetParser {
+
+  // Terms-facet parameters that have no effect on range facets. They used to 
be silently
+  // ignored; now they are rejected so users notice the mistake (SOLR-18482). 
The order is
+  // fixed so the error names the same parameter when several are present.
+  private static final List UNSUPPORTED_PARAMS =
+  List.of("limit", "offset", "sort", "prelim_sort", "overrequest", 
"overrefine", "refine");

Review Comment:
   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   I looked into this. Facet parsing is pull-based: each parser reads the keys 
it knows out of the args map and never looks at what is left over, so unknown 
keys are ignored by construction, and there is no single place where a check 
would go. A general version means a supported-key set per facet type (terms, 
query, range, heatmap) plus the shared domain keys, validated at the end of 
each parse; stats and sub-facet labels stay open because their keys are 
user-chosen. It is feasible, and the JSON request parser already does the same 
thing one level up, where unknown top-level keys are rejected. But it is a 
behavior change beyond this ticket: roughly 100 to 200 lines plus tests, and 
anything relying on the current leniency starts failing.
   
   My suggestion: keep this PR to the range facet as filed, and I will open a 
follow-up ticket for the general check and take it on. If you would rather see 
it here, I can do that instead.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] SOLR-18482: Reject unsupported parameters on JSON range facets [solr]

2026-10-05 Thread via GitHub


janhoy commented on code in PR #5009:
URL: https://github.com/apache/solr/pull/5009#discussion_r4189980661


##
solr/solr-ref-guide/modules/query-guide/pages/json-facet-api.adoc:
##
@@ -407,6 +407,10 @@ By default, the ranges used to compute range faceting 
between `start` and `end`
 Refer <>
 |===
 
+The range facet does not support the `limit`, `offset`, `sort`, `prelim_sort`, 
`overrequest`, `overrefine`, or `refine` parameters that terms facets accept.
+Using any of them in a range facet is rejected with a 400 error naming the 
parameter.

Review Comment:
   Unnecessary line
   ```suggestion
   ```



##
solr/core/src/java/org/apache/solr/search/facet/FacetRangeParser.java:
##
@@ -23,6 +23,13 @@
 import org.apache.solr.search.SyntaxError;
 
 class FacetRangeParser extends FacetParser {
+
+  // Terms-facet parameters that have no effect on range facets. They used to 
be silently
+  // ignored; now they are rejected so users notice the mistake (SOLR-18482). 
The order is
+  // fixed so the error names the same parameter when several are present.
+  private static final List UNSUPPORTED_PARAMS =
+  List.of("limit", "offset", "sort", "prelim_sort", "overrequest", 
"overrefine", "refine");

Review Comment:
   It would be far better if **any** illegal or mis-spelled facet parameter 
would cause a HTTP 400. Why would we want to silently accept `"foo":"bar"` in 
any request to Solr? This is a bit out of scope for the exact JIRA I filed. But 
perhaps we should consider whether it is an easy feat to implement this? Have 
not looked closely into the JSON DSL request parsing...



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



[PR] SOLR-18482: Reject unsupported parameters on JSON range facets [solr]

2026-10-02 Thread via GitHub


nick-boss-tech opened a new pull request, #5009:
URL: https://github.com/apache/solr/pull/5009

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-18482
   
   A `type: range` facet in the JSON Facet API accepted `limit`, `offset`, 
`sort`, `prelim_sort`, `overrequest`, `overrefine` and `refine` and silently 
ignored all of them: the buckets came back the same regardless. The same keys 
work on terms facets, so users copying them across got a plausible-looking 
wrong answer. `FacetRange` extends `FacetRequestSorted`, so the fields exist on 
the request object, but `FacetRangeParser` never read them and 
`FacetRangeProcessor` never consults them.
   
   Following the proposal on the ticket, `FacetRangeParser` now rejects each of 
these parameters with a 400 naming the parameter, e.g. "sort is not supported 
on range facets". The parameters are checked in a fixed order so a request 
carrying several of them fails on the same one every time. The ref guide Range 
Facet section now states which of the common facet parameters do not apply.
   
   **Compatibility change, intentional:** requests that include any of these 
parameters on a range facet were previously accepted (and the parameters 
silently dropped); they now return a 400. No new security boundary is added.
   
   Tests: cases added to `TestJsonFacetErrors.testRangeFacetsErrorCases` cover 
each of the seven parameters, the `{range:{...}}` form, the multi-parameter 
precedence, and a plain range facet as a control. `TestJsonFacetErrors` and 
`TestJsonRangeFacets` pass (15 tests), Error Prone clean, `:solr:core:check -x 
test` passes.
   
   Changelog: 
`changelog/unreleased/SOLR-18482-range-facet-unsupported-params.yml` (fixed)
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. Nick 
Shanin directed the work and takes responsibility for this contribution.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]