From b5ffab7ece30c6c80e50c0605028c625f8c112b0 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Tue, 21 Apr 2026 21:02:33 +0300 Subject: [PATCH] fix(command_trackers): allow system-shared command configs (user_id=0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creating or updating a command tracker failed with 404 "Command config not found" when the selected config was a system default (seeded with user_id=0). The LIST endpoint already accepts both owned and system-shared rows via or_(CommandConfig.user_id == user.id, CommandConfig.user_id == 0) so the frontend legitimately offered a user_id=0 option — the POST and PATCH handlers then rejected it. Align the create/update checks with the list behavior: config.user_id not in (user.id, 0) --- .../src/notify_bridge_server/api/command_trackers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/server/src/notify_bridge_server/api/command_trackers.py b/packages/server/src/notify_bridge_server/api/command_trackers.py index 262c60b..408b825 100644 --- a/packages/server/src/notify_bridge_server/api/command_trackers.py +++ b/packages/server/src/notify_bridge_server/api/command_trackers.py @@ -72,9 +72,9 @@ async def create_command_tracker( if not provider or provider.user_id != user.id: raise HTTPException(status_code=404, detail="Provider not found") - # Validate command config exists and user owns it + # Validate command config exists and is accessible (owned or system-shared) config = await session.get(CommandConfig, body.command_config_id) - if not config or config.user_id != user.id: + if not config or config.user_id not in (user.id, 0): raise HTTPException(status_code=404, detail="Command config not found") # Validate provider_type matches @@ -119,10 +119,10 @@ async def update_command_tracker( updates = body.model_dump(exclude_unset=True) - # If changing command_config_id, validate ownership and provider_type match + # If changing command_config_id, validate accessibility and provider_type match if "command_config_id" in updates and updates["command_config_id"] is not None: config = await session.get(CommandConfig, updates["command_config_id"]) - if not config or config.user_id != user.id: + if not config or config.user_id not in (user.id, 0): raise HTTPException(status_code=404, detail="Command config not found") provider = await session.get(ServiceProvider, tracker.provider_id) if provider and config.provider_type != provider.type: