Commit Graph

364 Commits

Author SHA1 Message Date
Classic298
8979987eed fix: drop extra='allow' on FolderForm and FolderUpdateForm (#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.
2026-04-13 16:14:00 -05:00
Timothy Jaeryang Baek
31406caa79 refac 2026-04-13 15:13:14 -05:00
Timothy Jaeryang Baek
57784706e4 refac 2026-04-12 19:34:45 -05:00
Timothy Jaeryang Baek
3c2c611ba9 refac 2026-04-12 18:49:34 -05:00
Timothy Jaeryang Baek
a359262616 refac 2026-04-12 18:48:06 -05:00
Timothy Jaeryang Baek
25898116ea chore: format 2026-04-12 18:12:59 -05:00
Timothy Jaeryang Baek
27169124f2 refac: async db 2026-04-12 14:22:11 -05:00
Classic298
71a39dbac1 fix: filter on is_active in channel membership checks (#23623)
is_user_channel_member and is_user_channel_manager did not filter on is_active, allowing deactivated members to retain read/write access to group channels via direct API calls.
2026-04-12 11:13:51 -05:00
Timothy Jaeryang Baek
406251c2f3 enh: automation 2026-04-11 17:06:58 -06:00
Timothy Jaeryang Baek
09f6d7ba57 refac 2026-04-11 16:55:20 -06:00
Timothy Jaeryang Baek
53eadb7df7 refac 2026-04-02 22:34:51 -05:00
Timothy Jaeryang Baek
4dea4fdf54 refac 2026-04-02 08:34:49 -05:00
Timothy Jaeryang Baek
a71d927a0c chore: format 2026-04-02 08:11:06 -05:00
Timothy Jaeryang Baek
640dbb6a28 refac 2026-04-02 08:09:57 -05:00
Timothy Jaeryang Baek
60e4d75174 refac 2026-04-02 02:50:05 -05:00
Algorithm5838
a28ea36657 perf: inline update_chat_title_by_id into single DB context (#23214) 2026-04-01 07:06:16 -05:00
Timothy Jaeryang Baek
15883e5229 refac 2026-04-01 06:00:53 -05:00
Timothy Jaeryang Baek
0e5696de74 refac 2026-04-01 05:55:48 -05:00
Timothy Jaeryang Baek
c8ef5a4f38 chore: format 2026-04-01 04:36:02 -05:00
Timothy Jaeryang Baek
53583f8d83 refac 2026-04-01 04:33:30 -05:00
Timothy Jaeryang Baek
0638b9f56c refac 2026-04-01 04:00:18 -05:00
Timothy Jaeryang Baek
fe8a3d9f83 refac 2026-04-01 00:55:52 -05:00
Timothy Jaeryang Baek
90319593d0 refac 2026-04-01 00:35:11 -05:00
Timothy Jaeryang Baek
e6f38f52c8 feat: automation 2026-03-31 23:36:01 -05:00
Algorithm5838
1c5e84ddf2 perf: project only Chat.id in delete_shared_chats_by_user_id (#23216) 2026-03-30 05:15:12 -05:00
Algorithm5838
9cc3ffb4a9 perf: update_last_active_by_id via single UPDATE (#23215) 2026-03-30 04:14:33 -05:00
Timothy Jaeryang Baek
bcb71bb520 feat: tasks 2026-03-29 18:01:04 -05:00
Timothy Jaeryang Baek
11f52921dc refac 2026-03-26 17:40:56 -05:00
Timothy Jaeryang Baek
90ca2e9b0f refac 2026-03-24 20:48:10 -05:00
Timothy Jaeryang Baek
968462609f refac 2026-03-24 18:05:19 -05:00
Timothy Jaeryang Baek
f7e07f3ca1 chore: format 2026-03-24 06:07:20 -05:00
Timothy Jaeryang Baek
ade617efa8 refac 2026-03-24 04:49:48 -05:00
Timothy Jaeryang Baek
945275faae refac 2026-03-22 06:58:58 -05:00
Algorithm5838
52e227f425 fix: add from_attributes to FunctionResponse (#22924) 2026-03-21 19:38:41 -05:00
Timothy Jaeryang Baek
93407ba316 refac 2026-03-21 18:21:25 -05:00
Timothy Jaeryang Baek
de3317e26b refac 2026-03-17 17:58:01 -05:00
Timothy Jaeryang Baek
f9756de693 refac 2026-03-15 17:35:06 -05:00
Timothy Jaeryang Baek
1364df0913 refac 2026-03-08 18:26:36 -05:00
Timothy Jaeryang Baek
2cb28369b7 refac 2026-03-08 18:08:12 -05:00
Classic298
caf3362be8 fix: add missing group_id filter to analytics token usage query (#22167)
The get_token_usage_by_user query lacked group_id filtering, while the
companion get_message_count_by_user query already supported it. When an
admin filtered analytics by user group, message counts were correctly
scoped to the group but token usage totals included data from all users.

Add the group_id parameter and subquery filter to get_token_usage_by_user,
matching the pattern used by get_message_count_by_user and other analytics
queries, and pass group_id through from the analytics endpoint.
2026-03-08 17:11:12 -05:00
Timothy Jaeryang Baek
b1048fc9bc refac 2026-03-07 20:22:01 -06:00
Classic298
223c14f48b fix: add deterministic tiebreaker to all paginated chat queries (#22387)
Add Chat.id as a secondary sort key to all paginated chat queries
that use offset/limit pagination. When multiple chats share the same
updated_at timestamp, the database does not guarantee a stable order
across page boundaries, causing chats to appear on multiple pages.

This produces duplicate keys in the Svelte sidebar each-block
(each_key_duplicate error). Adding Chat.id as a tiebreaker ensures
fully deterministic ordering.

Extends the fix from #22383 (which addressed get_chat_ids_by_model_id)
to all remaining paginated chat queries.
2026-03-07 20:16:50 -06:00
Timothy Jaeryang Baek
3ceaa107ab chore: format 2026-03-07 20:14:32 -06:00
Timothy Jaeryang Baek
8913f37c3d enh: create subfolder
Co-Authored-By: Colin Chen <1207878+silenceroom@users.noreply.github.com>
2026-03-07 19:45:43 -06:00
Classic298
d1975b740b fix: add deterministic ordering to chat_ids pagination query to prevent duplicates (#22383) 2026-03-07 20:19:44 -05:00
Timothy Jaeryang Baek
6d9996e599 refac 2026-03-06 20:12:37 -06:00
Classic298
d93cb3658d perf(models): batch-fetch function valves to eliminate N+1 queries (#22301)
* perf(models): batch-fetch function valves to eliminate N+1 queries

get_action_priority() called Functions.get_function_valves_by_id()
individually for every action on every model — an N+1 query pattern
that issued one DB round-trip per (action x model) pair.

Add Functions.get_function_valves_by_ids() that fetches all valves in
a single WHERE IN query, then look up each action's valves from the
pre-fetched dict inside get_action_priority().

No functional change — same priority resolution, same sort order.

* Update models.py

* Update models.py
2026-03-06 15:56:01 -06:00
Timothy Jaeryang Baek
80ad5fd2d0 refac 2026-03-01 14:06:26 -06:00
Timothy Jaeryang Baek
2cbba2a28a chore: format 2026-03-01 13:29:06 -06:00
Timothy Jaeryang Baek
0fff2fbcab refac 2026-03-01 13:23:39 -06:00