Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlers_user: Include db err in the internal error #984

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/controlplane/handlers_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,25 @@ func (s *Server) CreateUser(ctx context.Context,
FirstName: *stringToNullString(in.FirstName), LastName: *stringToNullString(in.LastName),
IsProtected: *in.IsProtected, NeedsPasswordChange: needsPassPtr})
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to create user")
return nil, status.Errorf(codes.Internal, "failed to create user: %s", err)
}

// now attach the groups and roles
for _, id := range in.GroupIds {
_, err := qtx.AddUserGroup(ctx, db.AddUserGroupParams{UserID: user.ID, GroupID: id})
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to add user to group")
return nil, status.Errorf(codes.Internal, "failed to add user to group: %s", err)
}
}
for _, id := range in.RoleIds {
_, err := qtx.AddUserRole(ctx, db.AddUserRoleParams{UserID: user.ID, RoleID: id})
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to add user to role")
return nil, status.Errorf(codes.Internal, "failed to add user to role: %s", err)
}
}
err = s.store.Commit(tx)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to commit transaction")
return nil, status.Errorf(codes.Internal, "failed to commit transaction: %s", err)
}

return &pb.CreateUserResponse{Id: user.ID, OrganizationId: user.OrganizationID, Email: &user.Email.String,
Expand Down