ispringer opened a new pull request, #5290: URL: https://github.com/apache/solr/pull/5290
https://issues.apache.org/jira/browse/SOLR-18620 # Description Follow-up to SOLR-17775. The `preFetchDocs` param and the prefetch cache in `ValueSourceAugmenter` have a few rough edges: - `preFetchDocs=abc` throws a `NumberFormatException` and `preFetchDocs=-1` throws a `NegativeArraySizeException` (from `new int[-1]` in `setContext`). Both surface as 500s instead of 400s. - The public constructor now calls `qparser.getParam(...)`, so passing a null `QParser` (previously fine, since it was only stored) throws an NPE. - When `setContext` gets a context with no DocList, it returns before replacing `cachedValuesById`, so a reused transformer can serve values cached against an earlier searcher. # Solution - Parse `preFetchDocs` in a helper that throws `SolrException(BAD_REQUEST)` for non-numeric or negative values, and falls back to the default of 1000 when the QParser is null. - Clear `cachedValuesById` at the start of every `setContext`, before the early return. Developed with Claude Code (Opus 5.5) assisting; I reviewed the changes. # Tests Added `TestValueSourceAugmenterPrefetchLimit` (the SOLR-18181 version of this test is on `branch_9x` but not `main`), with assertions that every returned doc has the function value and that it equals the doc's `id`, below and above the prefetch limit. New cases cover `preFetchDocs=0`, invalid values (`abc`, `-1`) returning 400, a null QParser, and a unit test showing `setContext` with no DocList clears the cache. Ran `TestValueSourceAugmenterPrefetchLimit`, `ReturnFieldsTest`, `TestPseudoReturnFields`, and `./gradlew :solr:core:check -x test`. # Checklist - [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability. - [x] I have created a Jira issue and added the issue ID to my pull request title. - [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation) - [x] I have developed this patch against the `main` branch. - [ ] I have run `./gradlew check`. - [x] I have added tests for my changes. - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide) - [x] I have added a [changelog entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my change 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
