Skip to content

Commit 8979987

Browse files
authored
fix: drop extra='allow' on FolderForm and FolderUpdateForm (open-webui#23648)
* fix: drop extra='allow' on FolderForm and FolderUpdateForm These request models were configured to accept arbitrary extra fields, which were then merged into the folder row via form_data.model_dump(). In insert_new_folder the server-assigned user_id is placed before the form spread, so a client-supplied user_id in the request body would override it and the folder would be persisted against another account. Strictly typed inputs are the correct shape for these endpoints — the client has no legitimate reason to send fields beyond the declared ones, and dropping extra='allow' closes the mass-assignment sink at the validation layer instead of relying on every callsite to merge fields in the right order. * fix: reject unknown fields on FolderForm and FolderUpdateForm Address review feedback: dropping extra='allow' fell back to Pydantic v2's default extra='ignore', which only silently drops unknown fields instead of rejecting them. The intent for these request models is a strict input contract — fail fast when a client sends anything the server does not expect — so explicitly set extra='forbid'. This also makes the hardening visible in the form definition rather than implicit in the default.
1 parent cd55c3e commit 8979987

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

backend/open_webui/models/folders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ class FolderForm(BaseModel):
7474
data: Optional[dict] = None
7575
meta: Optional[dict] = None
7676
parent_id: Optional[str] = None
77-
model_config = ConfigDict(extra='allow')
77+
model_config = ConfigDict(extra='forbid')
7878

7979

8080
class FolderUpdateForm(BaseModel):
8181
name: Optional[str] = None
8282
data: Optional[dict] = None
8383
meta: Optional[dict] = None
84-
model_config = ConfigDict(extra='allow')
84+
model_config = ConfigDict(extra='forbid')
8585

8686

8787
class FolderTable:

0 commit comments

Comments
 (0)