From 01c3bd4c81699c31871f7845d983bdf68d8797fa Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 19 Aug 2026 23:20:52 -0700 Subject: [PATCH] test: explicit keyless Firecrawl selection asserts the keyless cloud route MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The salvaged #50659 behavior makes 'firecrawl selected, no creds' a WORKING keyless state, so the old expectation (hard error naming FIRECRAWL_API_KEY) is stale. The test now mocks httpx and asserts the request routes to api.firecrawl.dev with results returned — still proving keyless Tavily can't silently take over, which was the test's point. Also stops the test making a real network call in CI. --- tests/tools/test_web_providers.py | 39 +++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/tools/test_web_providers.py b/tests/tools/test_web_providers.py index f02bc9b311..9a07f4390a 100644 --- a/tests/tools/test_web_providers.py +++ b/tests/tools/test_web_providers.py @@ -216,25 +216,50 @@ class TestUnconfiguredErrorEnvelopeParity: assert "results" not in result - def test_explicit_firecrawl_unconfigured_emits_top_level_error(self, monkeypatch): - """``web.backend: firecrawl`` with no creds still uses the Firecrawl - error envelope — keyless Tavily must not silently take over. + def test_explicit_firecrawl_unconfigured_uses_firecrawl_keyless(self, monkeypatch): + """``web.backend: firecrawl`` with no creds routes through Firecrawl's + keyless cloud client (PR #50659 salvage) — keyless Tavily must not + silently take over, and the request must hit api.firecrawl.dev. """ from tools import web_tools + from plugins.web.firecrawl import provider as fc self._clear_web_creds(monkeypatch) monkeypatch.setattr(web_tools, "_firecrawl_client", None, raising=False) monkeypatch.setattr(web_tools, "_firecrawl_client_config", None, raising=False) monkeypatch.setattr(web_tools, "_ddgs_package_importable", lambda: False) monkeypatch.setattr(web_tools, "_load_web_config", lambda: {"backend": "firecrawl"}) + monkeypatch.setattr(fc, "_load_web_config", lambda: {"backend": "firecrawl"}, raising=False) monkeypatch.setattr(web_tools, "_is_tool_gateway_ready", lambda: False) monkeypatch.setattr(web_tools, "check_firecrawl_api_key", lambda: False) + calls = {} + + class _FakeResponse: + status_code = 200 + + def raise_for_status(self): + return None + + def json(self): + return { + "success": True, + "data": [ + {"url": "https://example.com", "title": "Example", + "description": "desc"}, + ], + } + + def _fake_post(url, **kwargs): + calls["url"] = url + return _FakeResponse() + + monkeypatch.setattr(fc.httpx, "post", _fake_post) + result = json.loads(web_tools.web_search_tool("hello world", limit=3)) - assert "error" in result, f"expected top-level 'error' key, got {result}" - assert "Error searching web:" in result["error"] - assert "FIRECRAWL_API_KEY" in result["error"] - assert "results" not in result + assert result.get("success") is True, result + assert calls["url"].startswith("https://api.firecrawl.dev"), calls + assert result["data"]["web"], result class TestDispatchersTriggerPluginDiscovery: