[arvados] updated: 2.7.0-5933-g972b62e2bb

git repository hosting git at public.arvados.org
Fri Feb 2 16:17:47 UTC 2024


Summary of changes:
 lib/controller/integration_test.go |  2 +-
 services/api/app/models/user.rb    | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

       via  972b62e2bb581832cb7cfafce71e3cc6794e4361 (commit)
      from  9f487917d8c2aa3958473dd1c11dc584485c1229 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 972b62e2bb581832cb7cfafce71e3cc6794e4361
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Feb 2 11:17:03 2024 -0500

    21304: Handle user record updates with empty string username
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/lib/controller/integration_test.go b/lib/controller/integration_test.go
index fc1f705175..4bf7a03447 100644
--- a/lib/controller/integration_test.go
+++ b/lib/controller/integration_test.go
@@ -971,8 +971,8 @@ func (s *IntegrationSuite) TestSetupUserWithVM(c *check.C) {
 			"hostname": "example",
 		},
 		})
+	c.Assert(err, check.IsNil)
 	c.Check(outVM.UUID[0:5], check.Equals, "z3333")
-	c.Check(err, check.IsNil)
 
 	// Make sure z3333 user list is up to date
 	_, err = conn3.UserList(rootctx3, arvados.ListOptions{Limit: 1000})
diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb
index 212b0b6ce3..5a95fb0b88 100644
--- a/services/api/app/models/user.rb
+++ b/services/api/app/models/user.rb
@@ -656,13 +656,16 @@ SELECT target_uuid, perm_level
 
     remote_should_be_active = should_activate && remote_user[:is_invited] != false && remote_user[:is_active] == true
 
+    # Make sure blank username is nil
+    remote_user[:username] = nil if remote_user[:username] == ""
+
     begin
       user = User.create_with(email: remote_user[:email],
                               username: remote_user[:username],
                               first_name: remote_user[:first_name],
                               last_name: remote_user[:last_name],
-                              is_active: remote_should_be_active
-      ).find_or_create_by(uuid: remote_user[:uuid])
+                              is_active: remote_should_be_active,
+                             ).find_or_create_by(uuid: remote_user[:uuid])
     rescue ActiveRecord::RecordNotUnique
       retry
     end
@@ -711,6 +714,14 @@ SELECT target_uuid, perm_level
           end
           raise # Not the issue we're handling above
         end
+      elsif user.new_record?
+        begin
+          user.save!
+        rescue => e
+          Rails.logger.debug "Error saving user record: #{$!}"
+          Rails.logger.debug "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
+          raise
+        end
       end
 
       if remote_should_be_unsetup

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list