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

[AMBARI-22882] Long cannot be cast to String error when changing a user's password #235

Merged
merged 1 commit into from
Jan 31, 2018
Merged

Conversation

rlevas
Copy link
Contributor

@rlevas rlevas commented Jan 30, 2018

What changes were proposed in this pull request?

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
{ 
  "Users" : {
    "user_name" : "myuser",
    "password" : "hadoop"
  }
}
  1. Change the user's password (using either the Ambari UI or REST API via the users entry point)
PUT /api/v1/users/myuser
{ 
  "Users" : {
    "old_password" : "hadoop"
    "password" : "hadoop1234"
  }
}
{
  "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.

How was this patch tested?

Manually tested using the REST API and UI.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31:41 min
[INFO] Finished at: 2018-01-30T15:34:11-05:00
[INFO] Final Memory: 105M/1900M
[INFO] ------------------------------------------------------------------------

Please review Ambari Contributing Guide before opening a pull request.

@asfgit
Copy link

asfgit commented Jan 31, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/351/
Test PASSed.

@rlevas rlevas merged commit e40e7e5 into apache:trunk Jan 31, 2018
@rlevas rlevas deleted the AMBARI-22882 branch January 31, 2018 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants