mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-08 00:02:20 +03:00
fix(search): mark searxng-search as fallbackOnly to prevent auto-select without instance (#9543)
Closes #9543
This commit is contained in:
committed by
GitHub
parent
e4e0c254ea
commit
616175a93e
1
changelog.d/fixes/9543-searxng-auto-select.md
Normal file
1
changelog.d/fixes/9543-searxng-auto-select.md
Normal file
@@ -0,0 +1 @@
|
||||
- fix(search): mark searxng-search as fallbackOnly to prevent auto-select without instance (#9543)
|
||||
@@ -207,6 +207,7 @@ export const SEARCH_PROVIDERS: Record<string, SearchProviderConfig> = {
|
||||
maxMaxResults: 50,
|
||||
timeoutMs: 10_000,
|
||||
cacheTTLMs: 3 * 60 * 1000,
|
||||
fallbackOnly: true,
|
||||
},
|
||||
|
||||
"ollama-search": {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
30
tests/unit/search-select-provider-searxng-bug-9543.test.ts
Normal file
30
tests/unit/search-select-provider-searxng-bug-9543.test.ts
Normal file
@@ -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");
|
||||
});
|
||||
Reference in New Issue
Block a user