open-webui/backend/open_webui/utils
Claude ae8ef975ea
fix: apply custom model fallback before the base-model access check
With ENABLE_CUSTOM_MODEL_FALLBACK enabled, chatting with a custom
workspace model whose base model was removed still failed with "Model
not found" for non-admin users. The access check ran before the
fallback resolution and walked the preset's base_model_id chain;
has_base_model_access treats a base model without a model-table row as
admin-only, so regular users were rejected before the fallback to the
default (Selected) model could ever apply. Admins bypass the access
check by default, which is why the fallback only appeared to work for
them.

Resolve the fallback model first, and when one applies, skip the
missing base-model hop on the requested preset and enforce access on
the fallback model that will actually serve the chat instead.
check_model_access gains a check_base_model flag for this; all other
callers keep the default chain enforcement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sc922g12Yp16TdcCt74AWi
2026-08-12 11:38:16 +00:00
..
access_control refac: share one folder write-access check across chat folder_id paths (#28366) 2026-08-10 19:17:18 -06:00
images perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
mcp refac 2026-06-29 11:56:00 -05:00
telemetry refac(telemetry): drop deprecated semconv SpanAttributes subclass (#25784) 2026-06-29 02:05:34 -05:00
actions.py fix: enforce action availability and model access on the chat action route (#27243) 2026-07-23 12:23:05 -04:00
anthropic.py refac 2026-07-31 17:41:14 -04:00
asgi_middleware.py fix: report sub-second timings in the X-Process-Time header (#27368) 2026-07-23 18:09:23 -05:00
audit.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
auth.py refac 2026-08-10 22:36:42 -06:00
automations.py refac 2026-08-05 10:37:38 -05:00
calendar.py refac 2026-07-31 17:30:47 -04:00
channels.py refac 2026-03-17 17:58:01 -05:00
chat.py perf: build info log messages lazily so raising the log level actually saves work (#27837) 2026-08-02 15:39:10 -05:00
chat_fork.py refac 2026-07-23 02:54:56 -04:00
chat_id.py refac 2026-07-26 21:12:14 -04:00
chat_variables.py refac 2026-07-31 17:41:14 -04:00
code_interpreter.py refac 2026-07-31 17:41:14 -04:00
context_compaction.py refac 2026-08-11 01:15:05 -06:00
embeddings.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
files.py refac 2026-07-23 21:29:33 -04:00
filter.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00
groups.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
headers.py chore: format 2026-07-27 00:12:47 -04:00
json_codec.py perf: take the orjson fast path for ensure_ascii=False callers (#27841) 2026-07-31 20:39:10 -05:00
json_response.py perf: optional orjson JSON codec behind ENABLE_ORJSON (#27583) 2026-07-27 03:45:37 -04:00
logger.py perf: stop formatting every exported log record twice under OTEL log export (#27840) 2026-08-10 23:13:52 -06:00
memory.py refac 2026-08-10 19:28:21 -06:00
middleware.py refac 2026-08-11 01:15:05 -06:00
misc.py refactor: walk chat message history by map key (#28034) 2026-08-10 23:24:41 -06:00
model_ids.py refac 2026-07-26 23:09:22 -04:00
models.py fix: apply custom model fallback before the base-model access check 2026-08-12 11:38:16 +00:00
notifications.py refac 2026-07-27 19:39:36 -04:00
oauth.py refac 2026-08-10 23:13:10 -06:00
payload.py refac 2026-08-11 01:17:19 -06:00
pdf_generator.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
plugin.py perf: build info log messages lazily so raising the log level actually saves work (#27837) 2026-08-02 15:39:10 -05:00
rate_limit.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
redis.py fix: Set default Redis socket timeout to None (#27104) 2026-07-27 00:30:00 -04:00
response.py refac 2026-07-31 17:41:14 -04:00
sanitize.py refac 2026-03-17 17:58:01 -05:00
security_headers.py perf: stop recomputing static work in per-response ASGI middlewares (#27229) 2026-07-23 12:29:01 -04:00
session_pool.py refac 2026-07-27 04:17:00 -04:00
subagents.py refac 2026-08-10 20:13:03 -06:00
task.py refac 2026-06-19 00:16:06 +02:00
terminals.py refac 2026-08-08 15:47:10 -06:00
timers.py refac 2026-07-31 17:41:14 -04:00
tools.py refac 2026-08-10 19:44:56 -06:00
validate.py refac 2026-07-27 19:39:36 -04:00
valves.py refac 2026-07-31 17:41:14 -04:00
webhook.py perf: build debug log messages lazily so disabled debug logs cost nothing (#27834) 2026-07-31 19:09:01 -05:00