diff --git a/nextcloud_mcp_server/config.py b/nextcloud_mcp_server/config.py index 97783d9c1..a8d7c3f29 100644 --- a/nextcloud_mcp_server/config.py +++ b/nextcloud_mcp_server/config.py @@ -1731,7 +1731,20 @@ def __post_init__(self): # rather than raise: the prefix set is the gateway's, not a closed # universe, and refusing to boot over a model name we cannot validate # would be worse than saying so. - if self.search_rerank_enabled and self.search_rerank_url: + # + # "Explicit URL" does NOT imply "not the gateway": pointing + # SEARCH_RERANK_URL at the gateway's own /v1/rerank is a legitimate + # configuration (it is how you pin the endpoint while still using the + # gateway), and the routing prefix is correct there. Only warn when the + # URL is somewhere OTHER than the configured gateway — otherwise the + # warning fires on a working setup and trains operators to ignore it. + _direct_rerank = bool(self.search_rerank_url) and not ( + self.embedding_gateway_url + and self.search_rerank_url.startswith( + self.embedding_gateway_url.rstrip("/") + ) + ) + if self.search_rerank_enabled and _direct_rerank: _prefix, _, _bare = self.search_rerank_model.partition("/") if _prefix in GATEWAY_MODEL_NAMESPACES: logger.warning( diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 80a4d8f9a..611ee5f4c 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -357,6 +357,26 @@ def test_direct_url_warns_about_the_gateway_namespaced_default_model(self, caplo assert "SEARCH_RERANK_MODEL" in caplog.text assert "BAAI/bge-reranker-v2-m3" in caplog.text + @patch.dict( + os.environ, + { + "SEARCH_RERANK_ENABLED": "true", + "EMBEDDING_GATEWAY_URL": "https://gw.example", + "SEARCH_RERANK_URL": "https://gw.example/v1/rerank", + }, + clear=True, + ) + def test_rerank_url_pointing_at_the_gateway_is_quiet(self, caplog): + """Pinning SEARCH_RERANK_URL to the gateway's OWN /v1/rerank is a valid + configuration -- the routing prefix is correct there. Warning on it fires + on a working setup, which is how operators learn to ignore warnings.""" + _reload_config() + with caplog.at_level(logging.WARNING, logger="nextcloud_mcp_server.config"): + settings = get_settings() + + assert settings.search_rerank_model == "local/BAAI/bge-reranker-v2-m3" + assert "SEARCH_RERANK_MODEL" not in caplog.text + @patch.dict( os.environ, { diff --git a/third_party/astrolabe b/third_party/astrolabe index ccd2d180e..318fba63c 160000 --- a/third_party/astrolabe +++ b/third_party/astrolabe @@ -1 +1 @@ -Subproject commit ccd2d180e88d5ba71948c4617159cf654481a9c4 +Subproject commit 318fba63cdd85e61b8bee8b76877e6c52b0b7fe0