18801: Fixes the regression by ignoring the case where api_token isn't there.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 25 Feb 2022 18:54:57 +0000 (15:54 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 25 Feb 2022 18:54:57 +0000 (15:54 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

services/api/app/models/api_client_authorization.rb

index c74c1ce5bf353a951e7c6ca076f2a4fd426f3038..993a49e5b75e7ecfb782a306df16c74b37fbed4a 100644 (file)
@@ -35,7 +35,12 @@ class ApiClientAuthorization < ArvadosModel
   UNLOGGED_CHANGES = ['last_used_at', 'last_used_by_ip_address', 'updated_at']
 
   def assign_random_api_token
-    self.api_token ||= rand(2**256).to_s(36)
+    begin
+      self.api_token ||= rand(2**256).to_s(36)
+    rescue ActiveModel::MissingAttributeError
+      # Ignore the case where self.api_token doesn't exist, which happens when
+      # the select=[...] is used.
+    end
   end
 
   def owner_uuid