add guards to reject missing sub commands

This commit is contained in:
Josh Hawkins 2026-04-02 06:17:59 -05:00
parent adc8c2a6e8
commit a7f70e1334
2 changed files with 20 additions and 0 deletions

View File

@ -1224,6 +1224,15 @@ def camera_set(
status_code=400, status_code=400,
) )
if not sub_command and feature in _SUB_COMMAND_FEATURES:
return JSONResponse(
content={
"success": False,
"message": f"Feature '{feature}' requires a sub-command (e.g. mask or zone name)",
},
status_code=400,
)
if camera_name == "*": if camera_name == "*":
cameras = list(frigate_config.cameras.keys()) cameras = list(frigate_config.cameras.keys())
elif camera_name not in frigate_config.cameras: elif camera_name not in frigate_config.cameras:

View File

@ -118,10 +118,21 @@ class Dispatcher:
try: try:
if command_type == "set": if command_type == "set":
# Commands that require a sub-command (mask/zone name)
sub_command_required = {
"motion_mask",
"object_mask",
"zone",
}
if sub_command: if sub_command:
self._camera_settings_handlers[command]( self._camera_settings_handlers[command](
camera_name, sub_command, payload camera_name, sub_command, payload
) )
elif command in sub_command_required:
logger.error(
"Command %s requires a sub-command (mask/zone name)",
command,
)
else: else:
self._camera_settings_handlers[command](camera_name, payload) self._camera_settings_handlers[command](camera_name, payload)
elif command_type == "ptz": elif command_type == "ptz":