From 616175a93e9feded9ffa23a3fef43d1788b493c2 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Thu, 6 Aug 2026 22:55:16 -0300 Subject: [PATCH] fix(search): mark searxng-search as fallbackOnly to prevent auto-select without instance (#9543) Closes #9543 --- changelog.d/fixes/9543-searxng-auto-select.md | 1 + open-sse/config/searchRegistry.ts | 1 + tests/unit/search-registry.test.ts | 4 +-- tests/unit/search-route.test.ts | 11 ++----- ...h-select-provider-searxng-bug-9543.test.ts | 30 +++++++++++++++++++ 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 changelog.d/fixes/9543-searxng-auto-select.md create mode 100644 tests/unit/search-select-provider-searxng-bug-9543.test.ts diff --git a/changelog.d/fixes/9543-searxng-auto-select.md b/changelog.d/fixes/9543-searxng-auto-select.md new file mode 100644 index 0000000000..2798fab967 --- /dev/null +++ b/changelog.d/fixes/9543-searxng-auto-select.md @@ -0,0 +1 @@ +- fix(search): mark searxng-search as fallbackOnly to prevent auto-select without instance (#9543) diff --git a/open-sse/config/searchRegistry.ts b/open-sse/config/searchRegistry.ts index 2b366547d3..b742ad4914 100644 --- a/open-sse/config/searchRegistry.ts +++ b/open-sse/config/searchRegistry.ts @@ -207,6 +207,7 @@ export const SEARCH_PROVIDERS: Record = { maxMaxResults: 50, timeoutMs: 10_000, cacheTTLMs: 3 * 60 * 1000, + fallbackOnly: true, }, "ollama-search": { diff --git a/tests/unit/search-registry.test.ts b/tests/unit/search-registry.test.ts index 138a13d83d..94c2dd84b3 100644 --- a/tests/unit/search-registry.test.ts +++ b/tests/unit/search-registry.test.ts @@ -201,7 +201,7 @@ test("selectProvider with unknown provider returns null", () => { test("selectProvider without argument returns cheapest provider", () => { const config = selectProvider(); assert.ok(config); - assert.equal(config.id, "searxng-search"); + assert.notEqual(config.id, "searxng-search"); }); test("selectProvider auto-selection never returns a fallbackOnly provider", () => { @@ -223,7 +223,7 @@ test("selectProvider still honors an explicit fallbackOnly provider", () => { test("selectProvider filters by search type support", () => { const config = selectProvider(undefined, "news"); assert.ok(config); - assert.equal(config.id, "searxng-search"); + assert.equal(config.id, "serper-search"); assert.equal(selectProvider("linkup-search", "news"), null); }); diff --git a/tests/unit/search-route.test.ts b/tests/unit/search-route.test.ts index 621381da65..ce634b4877 100644 --- a/tests/unit/search-route.test.ts +++ b/tests/unit/search-route.test.ts @@ -417,7 +417,7 @@ test("v1 search POST preserves stored SearXNG baseUrl for authless providers", a } }); -test("v1 search POST auto-select uses authless SearXNG when no API-key providers are configured", async () => { +test("v1 search POST returns 400 when auto-select finds no configured provider (searxng-search is now fallbackOnly)", async () => { const originalFetch = globalThis.fetch; let capturedUrl = ""; @@ -451,13 +451,8 @@ test("v1 search POST auto-select uses authless SearXNG when no API-key providers ); const body = (await response.json()) as any; - assert.equal(response.status, 200); - assert.equal( - capturedUrl, - "http://localhost:8888/search?q=auto+select+self+hosted+search&format=json&categories=general" - ); - assert.equal(body.provider, "searxng-search"); - assert.equal(body.results[0].title, "Auto-selected SearXNG result"); + assert.equal(response.status, 400); + assert.ok(body.error?.message || body.error); } finally { globalThis.fetch = originalFetch; } diff --git a/tests/unit/search-select-provider-searxng-bug-9543.test.ts b/tests/unit/search-select-provider-searxng-bug-9543.test.ts new file mode 100644 index 0000000000..b42b1885af --- /dev/null +++ b/tests/unit/search-select-provider-searxng-bug-9543.test.ts @@ -0,0 +1,30 @@ +import test from "node:test"; +import assert from "node:assert/strict"; + +const { SEARCH_PROVIDERS, selectProvider } = + await import("../../open-sse/config/searchRegistry.ts"); + +test("searxng-search has fallbackOnly: true (fix #9543)", () => { + const s = SEARCH_PROVIDERS["searxng-search"]; + assert.ok(s); + assert.equal(s.authType, "none"); + assert.equal(s.costPerQuery, 0); + assert.equal(s.fallbackOnly, true); +}); + +test("selectProvider does NOT auto-select searxng-search (fix #9543)", () => { + const auto = selectProvider(); + assert.ok(auto); + assert.notEqual(auto.id, "searxng-search"); +}); + +test("duckduckgo-free IS correctly fallbackOnly (design reference)", () => { + const d = SEARCH_PROVIDERS["duckduckgo-free"]; + assert.equal(d.fallbackOnly, true); +}); + +test("selectProvider with explicit searxng-search still works", () => { + const explicit = selectProvider("searxng-search", "web"); + assert.ok(explicit); + assert.equal(explicit.id, "searxng-search"); +});