Skip to content

permissions: PUT /api/permissions/roles/{id} with missing 'permissions' field silently wipes all role permissions #269

Description

@antosubash

Found by QA (browser fetch against a live app, reproduced): PUT /api/permissions/roles/{id} with body {} returns 200 and deletes every permission assigned to the role.

Root cause: RolePermissionsUpdate.permissions uses default_factory=list (modules/permissions/permissions/contracts/schemas.py), so a body that omits the field validates as an explicit empty list, and PermissionService.set_role_permissions treats the list as the full desired state — deleting all rows not in it.

Impact: an admin (or any client with permissions.manage) sending a malformed body can silently strip a role — including locking the admin role out of the role editor itself. Suggested fix: make permissions required in the update schema (explicit [] stays legal as a deliberate clear-all), so a missing field 422s instead of wiping.

Pre-existing on main (not related to PR #267); found during its QA cycle.

https://claude.ai/code/session_01HMniW4BEhpumUTFnWZVKVc

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpi-pr-openThe headless Pi worker opened a draft pull request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions