Uploaded image for project: 'Ambari'
  1. Ambari
  2. AMBARI-22882

Long cannot be cast to String error when changing a user's password

    XMLWordPrintableJSON

Details

    Description

      Long cannot be cast to String error when changing a user's password:

      30 Jan 2018 18:21:11,308 ERROR [ambari-client-thread-38] AbstractResourceProvider:353 - Caught AmbariException when modifying a resource
      org.apache.ambari.server.AmbariException: java.lang.Long cannot be cast to java.lang.String
      at org.apache.ambari.server.controller.internal.UserResourceProvider.addOrUpdateLocalAuthenticationSource(UserResourceProvider.java:559)
      at org.apache.ambari.server.controller.internal.UserResourceProvider.updateUsers(UserResourceProvider.java:486)
      at org.apache.ambari.server.controller.internal.UserResourceProvider.access$200(UserResourceProvider.java:69)
      at org.apache.ambari.server.controller.internal.UserResourceProvider$3.invoke(UserResourceProvider.java:264)
      at org.apache.ambari.server.controller.internal.UserResourceProvider$3.invoke(UserResourceProvider.java:261)
      at org.apache.ambari.server.controller.internal.AbstractResourceProvider.invokeWithRetry(AbstractResourceProvider.java:465)
      at org.apache.ambari.server.controller.internal.AbstractResourceProvider.modifyResources(AbstractResourceProvider.java:346)
      at org.apache.ambari.server.controller.internal.UserResourceProvider.updateResources(UserResourceProvider.java:261)
      at org.apache.ambari.server.controller.internal.ClusterControllerImpl.updateResources(ClusterControllerImpl.java:317)
      ...
      

      Steps to reproduce

      1. Create a LOCAL user account (using either the Ambari UI or REST API)
        POST /api/v1/users
        
        Payload
        { 
          "Users" : {
            "user_name" : "myuser",
            "password" : "hadoop"
          }
        }
        
      2. Change the user's password (using either the Ambari UI or REST API via the users entry point)
        PUT /api/v1/users/myuser
        
        Payload
        { 
          "Users" : {
            "old_password" : "hadoop"
            "password" : "hadoop1234"
          }
        }
        
        Response
        {
          "status" : 500,
          "message" : "org.apache.ambari.server.controller.spi.SystemException: An internal system exception occurred: java.lang.Long cannot be cast to java.lang.String"
        }
        

      Cause
      When building the internal request to set the user's password via the UserAuthenticationSource resource provider, the authentication source key is set as a Long. The UserAuthenticationSource resource provider expects this value to be a String.

      Solution
      The User resource provider should set the AuthenticationSourceInfo/source_id as a String value.

      Attachments

        Issue Links

          Activity

            People

              rlevas Robert Levas
              rlevas Robert Levas
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h