MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / _resolve_pref_url

Function _resolve_pref_url

web/pgadmin/llm/utils.py:288–314  ·  view source on GitHub ↗

Resolve an API URL preference against the allowlist. - User preference set and allowed: return it. - User preference set but rejected: log a warning and return '' WITHOUT falling back to the admin default. Silent substitution hides the rejection and routes the user's reques

(pref_name, config_default)

Source from the content-addressed store, hash-verified

286
287
288def _resolve_pref_url(pref_name, config_default):
289 """
290 Resolve an API URL preference against the allowlist.
291
292 - User preference set and allowed: return it.
293 - User preference set but rejected: log a warning and return ''
294 WITHOUT falling back to the admin default. Silent substitution
295 hides the rejection and routes the user's request to a
296 different provider (issue #9936).
297 - No user preference: return the admin's trusted config URL.
298 """
299 pref_url = _get_preference_value(pref_name)
300 if pref_url:
301 if validate_api_url(pref_url):
302 return pref_url
303 try:
304 from flask import current_app
305 current_app.logger.warning(
306 "LLM API URL preference '%s'=%r is not in "
307 "ALLOWED_LLM_API_URLS; ignoring. Add it to the "
308 "allowlist in config_local.py to permit this URL.",
309 pref_name, pref_url
310 )
311 except Exception:
312 pass
313 return ''
314 return config_default or ''
315
316
317def is_pref_api_url_rejected(pref_name):

Callers 4

get_anthropic_api_urlFunction · 0.85
get_openai_api_urlFunction · 0.85
get_ollama_api_urlFunction · 0.85
get_docker_api_urlFunction · 0.85

Calls 3

_get_preference_valueFunction · 0.85
validate_api_urlFunction · 0.85
warningMethod · 0.80

Tested by

no test coverage detected