Skip to content

Commit 7038f2a

Browse files
committed
🐛(backend) fix KeyError crash when role is undefined in request data
Use dict.get() instead of direct key access to prevent server crashes when role field is missing. Fix inherited from magnify project codebase.
1 parent b7dfafa commit 7038f2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/core/api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def validate(self, data):
3737
# Update
3838
self.instance
3939
and (
40-
data["role"] == models.RoleChoices.OWNER
40+
data.get("role") == models.RoleChoices.OWNER
4141
and not self.instance.resource.is_owner(user)
4242
or self.instance.role == models.RoleChoices.OWNER
4343
and not self.instance.user == user

0 commit comments

Comments
 (0)