fix(command_trackers): allow system-shared command configs (user_id=0)
Release / release (push) Successful in 59s

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)
This commit is contained in:
2026-04-21 21:02:33 +03:00
parent 28465f56f9
commit b5ffab7ece
@@ -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: