Skip to content

Commit 66645d5

Browse files
fregataaclaude
andcommitted
revert(BA-3696): Remove user UUID query from legacy GQL handlers
Revert the user_uuid DB lookups added to ModifyUser, DeleteUser, and PurgeUser mutations in gql_legacy/user.py back to main state. The API handler layer should not perform direct DB queries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent db246a7 commit 66645d5

1 file changed

Lines changed: 5 additions & 37 deletions

File tree

  • src/ai/backend/manager/api/gql_legacy

src/ai/backend/manager/api/gql_legacy/user.py

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,7 @@ class ModifyUserInput(graphene.InputObjectType): # type: ignore[misc]
956956
description="Added in 25.2.0. Supplementary group IDs assigned to processes running inside the container.",
957957
)
958958

959-
def to_action(
960-
self, email: str, user_uuid: UUID, graph_ctx: GraphQueryContext
961-
) -> ModifyUserAction:
959+
def to_action(self, email: str, graph_ctx: GraphQueryContext) -> ModifyUserAction:
962960
# Create PasswordInfo if password is being changed
963961
password_state = OptionalState[PasswordInfo].nop()
964962
if self.password is not Undefined and self.password is not None:
@@ -1029,7 +1027,6 @@ def to_action(
10291027
)
10301028
# Note: User update uses email for lookup, pk_value is not used
10311029
return ModifyUserAction(
1032-
user_uuid=user_uuid,
10331030
email=email,
10341031
updater=Updater(spec=spec, pk_value=email),
10351032
)
@@ -1046,11 +1043,8 @@ class PurgeUserInput(graphene.InputObjectType): # type: ignore[misc]
10461043
),
10471044
)
10481045

1049-
def to_action(
1050-
self, email: str, user_uuid: UUID, user_info_ctx: UserInfoContext
1051-
) -> PurgeUserAction:
1046+
def to_action(self, email: str, user_info_ctx: UserInfoContext) -> PurgeUserAction:
10521047
return PurgeUserAction(
1053-
user_uuid=user_uuid,
10541048
user_info_ctx=user_info_ctx,
10551049
email=email,
10561050
purge_shared_vfolders=OptionalState[bool].from_graphql(
@@ -1125,15 +1119,7 @@ async def mutate(
11251119

11261120
validate_user_mutation_props(props)
11271121

1128-
# Fetch user UUID first (needed for RBAC validation)
1129-
async with graph_ctx.db.begin_readonly_session() as db_session:
1130-
user_uuid = await db_session.scalar(
1131-
sa.select(users.c.uuid).where(users.c.email == email)
1132-
)
1133-
if user_uuid is None:
1134-
raise UserNotFound
1135-
1136-
action: ModifyUserAction = props.to_action(email, user_uuid, graph_ctx)
1122+
action: ModifyUserAction = props.to_action(email, graph_ctx)
11371123
res: ModifyUserActionResult = await graph_ctx.processors.user.modify_user.wait_for_complete(
11381124
action
11391125
)
@@ -1168,16 +1154,7 @@ async def mutate(
11681154
email: str,
11691155
) -> DeleteUser:
11701156
graph_ctx: GraphQueryContext = info.context
1171-
1172-
# Fetch user UUID first (needed for RBAC validation)
1173-
async with graph_ctx.db.begin_readonly_session() as db_session:
1174-
user_uuid = await db_session.scalar(
1175-
sa.select(users.c.uuid).where(users.c.email == email)
1176-
)
1177-
if user_uuid is None:
1178-
raise UserNotFound
1179-
1180-
action = DeleteUserAction(user_uuid=user_uuid, email=email)
1157+
action = DeleteUserAction(email)
11811158
await graph_ctx.processors.user.delete_user.wait_for_complete(action)
11821159
return cls(
11831160
ok=True,
@@ -1219,21 +1196,12 @@ async def mutate(
12191196
props: PurgeUserInput,
12201197
) -> PurgeUser:
12211198
graph_ctx: GraphQueryContext = info.context
1222-
1223-
# Fetch user UUID first (needed for RBAC validation)
1224-
async with graph_ctx.db.begin_readonly_session() as db_session:
1225-
user_uuid = await db_session.scalar(
1226-
sa.select(users.c.uuid).where(users.c.email == email)
1227-
)
1228-
if user_uuid is None:
1229-
raise UserNotFound
1230-
12311199
user_info_ctx = UserInfoContext(
12321200
uuid=graph_ctx.user["uuid"],
12331201
email=graph_ctx.user["email"],
12341202
main_access_key=graph_ctx.user["main_access_key"],
12351203
)
1236-
action = props.to_action(email, user_uuid, user_info_ctx)
1204+
action = props.to_action(email, user_info_ctx)
12371205

12381206
await graph_ctx.processors.user.purge_user.wait_for_complete(action)
12391207

0 commit comments

Comments
 (0)