fix(web): SearXNG honors SEARXNG_URL set via hermes config (#34290)#34367
Closed
Bartok9 wants to merge 1 commit into
Closed
fix(web): SearXNG honors SEARXNG_URL set via hermes config (#34290)#34367Bartok9 wants to merge 1 commit into
Bartok9 wants to merge 1 commit into
Conversation
…rch#34290) SearXNG provider read os.getenv(SEARXNG_URL) only. Users who set the URL via 'hermes config set SEARXNG_URL ...' or via the Hermes-managed .env file got 'SEARXNG_URL is not set' because the live process env was unchanged \u2014 those values are visible through hermes_cli.config.get_env_value() but are NOT necessarily exported to the running process environment. The same blind spot existed in tools/web_tools.py's _has_env helper that drives the auto-backend selection at line 156. After this fix, both layers agree on availability. Changes: 1. plugins/web/searxng/provider.py New _resolve_searxng_url() helper: try get_env_value() first, then os.getenv() fallback. Used by both is_available() and search() so they can never disagree. When both have a value, config wins \u2014 because 'hermes config set' is the user's authoritative declaration. 2. tools/web_tools.py _has_env() now does the same config-first lookup. The auto-backend selection at line 156 (and the same logic at line 216) now find SearXNG when it was set via config. The diagnostic print at line 1196 also uses the config-aware resolution so 'hermes tools' shows the actual URL the provider will use, not a stale shell value. POSIX behavior preserved for users who set SEARXNG_URL via shell exports / systemd Environment= \u2014 the os.getenv fallback still works identically. Tests (5 new in TestSearXNGConfigAwareEnvResolution): - Provider picks up SEARXNG_URL from get_env_value() when os.environ is empty (the NousResearch#34290 reproduction case). - Provider falls back to process env when config has nothing (legacy shell-export behavior preserved). - Provider reports unavailable when neither layer has a value. - _resolve_searxng_url prefers config over env when both are set. - tools/web_tools.py::_has_env is also config-aware for SEARXNG_URL so the backend selection logic agrees with the provider. All 29 tests in test_web_providers_searxng.py pass. Refs: NousResearch#34290 Closes: NousResearch#34290 Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
Contributor
Author
|
Closing in favor of #34306 (@Kailigithub), which makes the same SearXNG provider fix and is smaller + earlier. Differential: my PR also fixed If maintainers consider the \u2014 Bartok9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #34290
Problem
SearXNG provider read
os.getenv(SEARXNG_URL)only. Users who set the URL viahermes config set SEARXNG_URL ...or the Hermes-managed.envfile gotSEARXNG_URL is not set— those values are visible throughhermes_cli.config.get_env_value()but NOT necessarily exported to the running process env (gateway worker spawned via systemd, etc.).Same blind spot in
tools/web_tools.py::_has_env(drives auto-backend selection at line 156).Fix
plugins/web/searxng/provider.py— new_resolve_searxng_url()helper:get_env_value()first,os.getenv()fallback. Used by bothis_available()andsearch()so they can never disagree.tools/web_tools.py— same config-first lookup in_has_env. Diagnostic print at line 1196 also config-aware.POSIX behavior preserved for users who set via shell exports / systemd
Environment=.Tests (5 new)
get_env_value()when os.environ empty (the Bug: SearXNG provider ignores Hermes config env values for SEARXNG_URL #34290 repro)_resolve_searxng_urlprefers config over env when both set_has_envin web_tools is also config-aware$ python -m pytest tests/tools/test_web_providers_searxng.py === 29 passed in 0.35s ===🎻 Co-authored-by: Cursor cursoragent@cursor.com