davsclaus opened a new pull request, #29028: URL: https://github.com/apache/camel/pull/29028
Fixes [CAMEL-26203](https://issues.apache.org/jira/browse/CAMEL-26203). ### 1. A WebSearchRequest bean in the registry replaced the body on every endpoint **What was wrong:** `webSearchRequest` was `autowired = true`. With one `WebSearchRequest` bean in the registry, every `langchain4j-web-search` endpoint used it. The producer builds the request from the body only when that option is null, so the search terms in the body were ignored. The bean's `maxResults` was used as well, so the body became a List (or a single result) by the bean, not by the endpoint. The same applied to `additionalParams` (a `Map<String, Object>`, also `autowired = true`): the only `Map` bean of the registry was sent as the additional parameters of every search. This is the field next to it, so it is fixed here too. **What changed:** both options are no longer autowired. An endpoint uses them only when it refers to them (`webSearchRequest=#myRequest`). `webSearchEngine` stays autowired. ### 2. With maxResults=1 a result without content gave null, like no result **What was wrong:** with `resultType=CONTENT` (the default) the body was `content()` of the result, which is null when the engine gives only a title, link and snippet. Google Custom Search never gives content, and Tavily only with `includeRawContent(true)`, so with these engines the default gave null for every found result (a list of nulls with `maxResults` above 1). **What changed:** a result whose content is null or blank gives its snippet, for a single result and for each element of a List. This is what LangChain4j itself does when it turns a `WebSearchOrganicResult` into text (`copyToText()` uses the content, else the snippet). `SNIPPET` and `LANGCHAIN4J_WEB_SEARCH_ORGANIC_RESULT` are unchanged. No result still gives null. ### Tests - `LangChain4jWebSearchAutowireTest`: a `WebSearchRequest` bean in the registry no longer replaces the body; an endpoint that refers to it still uses it. - `LangChain4jWebSearchAdditionalParamsTest`: a `Map` bean in the registry is not sent; an endpoint that refers to it sends it. - `LangChain4jWebSearchContentTest`: a single result and a List give the snippet for a result with null or blank content; `SNIPPET` is unchanged. All use a fake `WebSearchEngine`. The 4 tests that cover the fixes failed before the fix. Module: 11 tests, 0 failures (`-Psourcecheck`). ### Docs and generated files - Component doc: the request is not autowired; the CONTENT fallback; the engine is autowired by type when it is the only one (the doc said "if its bound name is `web-search-engine`", which is not how autowiring works); the examples now refer to the bean names they bind. - `@BodyTypes` text updated (it said null when the engine gives no content). - Regenerated: component JSON, endpoint configurer, catalog JSON and doc, endpoint DSL. - Upgrade guide 4.24: an entry for both behaviour changes. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 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]
