[Rt-commit] rt branch 5.0/rest2-canonicalize-principal-exception created. rt-5.0.4-20-g62b2cae730

BPS Git Server git at git.bestpractical.com
Tue Jun 13 18:40:11 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/rest2-canonicalize-principal-exception has been created
        at  62b2cae730d6c5aff2a14d4067e3dc2c5f994857 (commit)

- Log -----------------------------------------------------------------
commit 62b2cae730d6c5aff2a14d4067e3dc2c5f994857
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Jun 10 03:37:27 2023 +0800

    Check return value of CanonicalizePrincipal in case username/email is invaild
    
    This is to get rid of the possible error like:
    
        Can't locate object method "Id" via package "0"
    
    This could happen if you try to add an invalid user/email to ticket watchers.
    
    With this commit, user will also be able to see the error message which
    helps debug.

diff --git a/lib/RT/REST2/Util.pm b/lib/RT/REST2/Util.pm
index 5317384652..0c53165782 100644
--- a/lib/RT/REST2/Util.pm
+++ b/lib/RT/REST2/Util.pm
@@ -563,8 +563,10 @@ sub update_role_members {
                     $principal_id = $_;
                 }
                 elsif ($record->can('CanonicalizePrincipal')) {
-                    ((my $principal), $msg) = $record->CanonicalizePrincipal(User => $_);
-                    $principal_id = $principal->Id;
+                    ((my $principal), $msg) = $record->CanonicalizePrincipal(User => $_, Type => $role);
+                    if ($principal) {
+                        $principal_id = $principal->Id;
+                    }
                 }
                 else {
                     my $user = RT::User->new($record->CurrentUser);

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list