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

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-8020
   
   ## What happens today
   
   **With `debug=true`, a request that hits a query limit can get a second 
debug entry after the real one.**
   
   When a component has already added its debug section, and a later component 
exits on a query limit, `SearchHandler` adds another `debug` entry. That entry 
holds only an empty `explain` section ([base 
code](https://github.com/nick-boss-tech/solr/blob/22a8cfebbbdb026437d10b0aa47bb66ffdb23a9a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java#L794-L798)).
 The response then has two debug entries, and JSON clients may keep only one of 
them. The ticket calls this an overwrite 
([ticket](https://issues.apache.org/jira/browse/SOLR-8020)).
   
   ## What this change does
   
   **`SearchHandler` adds its empty debug section only when the response has no 
debug entry yet.**
   
   The check is one extra condition ([SearchHandler.java 
L794-L800](https://github.com/nick-boss-tech/solr/blob/79f790523d2fcbc91670e5dab0d4b5940dc11c41/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java#L794-L800)).
 When the limit trips before any debug output exists, the empty section is 
still added, as before. The response, `numFound`, and the partial results flag 
are not changed by this patch.
   
   ## Proof
   
   **The new test fails on the base code with two debug entries and passes with 
this change.**
   
   - 
[`ComponentStageLimitsTest`](https://github.com/nick-boss-tech/solr/blob/79f790523d2fcbc91670e5dab0d4b5940dc11c41/solr/core/src/test/org/apache/solr/search/ComponentStageLimitsTest.java#L207-L240)
 5 of 5 passed at `79f790523d2`, verified 2026-10-05.
   - With only `SearchHandler.java` reverted to the base version, the new test 
`testLimitAfterDebugKeepsSingleDebugSection` fails with `expected:<1> but 
was:<2>`. The other four tests in the class pass in that run.
   - The test uses a test component that throws the limit exception after the 
debug component has run. It checks that the partial results flag is set, that 
`numFound` is above zero, that there is one debug entry, and that this entry is 
the real one (it contains `parsedquery`).
   
   ## Limits
   
   **The ticket also lists a reset `numFound` and a duplicate response. Main 
already avoids both, so this change covers only the debug entry.**
   
   - The short-circuit code adds the response list only when it is missing 
([SearchHandler.java 
L784](https://github.com/nick-boss-tech/solr/blob/79f790523d2fcbc91670e5dab0d4b5940dc11c41/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java#L784)).
 It does not change `numFound`.
   - The new test checks that `numFound` is above zero. It does not count 
response sections.
   
   Changelog: 
[changelog/unreleased/SOLR-8020-partial-results-single-debug.yml](https://github.com/nick-boss-tech/solr/blob/79f790523d2fcbc91670e5dab0d4b5940dc11c41/changelog/unreleased/SOLR-8020-partial-results-single-debug.yml)
   
   ### 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]

Reply via email to