fix: strip model params for read-only callers in the model list endpoint (#27004)

The per-id model endpoint (GET /api/v1/models/model) strips params, the system
prompt and other curated model config, for callers who only have read access.
The list endpoint (GET /api/v1/models/list) did not: it returned each
read-accessible model's full params, so a read-shared model exposed its
params.system to non-owner read-grant holders.

Mirror the per-id behaviour: compute write_access per item and drop params
before serialising when the caller lacks write access (not the owner, not an
admin under BYPASS_ADMIN_ACCESS_CONTROL and holding no write grant). The
model-card list UI does not render params, so this does not change
functionality.

Co-authored-by: bogdancherniy11-sudo <229690748+bogdancherniy11-sudo@users.noreply.github.com>
This commit is contained in:
Classic298
2026-07-27 01:51:29 -04:00
committed by GitHub
co-authored by bogdancherniy11-sudo
parent c05de13b4f
commit 3fe829acc2
+9 -9
View File
@@ -189,16 +189,16 @@ async def get_models(
data = add_chat_variables_schema(model.model_dump())
if data.get('meta'):
data['meta'].pop('profile_image_url', None)
items.append(
ModelAccessResponse(
**data,
write_access=(
(user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL)
or user.id == model.user_id
or model.id in writable_model_ids
),
)
write_access = (
(user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL)
or user.id == model.user_id
or model.id in writable_model_ids
)
# Strip params (system prompt and other curated config) for read-only
# callers, mirroring the per-id endpoint.
if not write_access:
data['params'] = {}
items.append(ModelAccessResponse(**data, write_access=write_access))
return ModelAccessListResponse(
items=items,