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

POST to api-umbrella/v1/users succeeds in 0.14.1 but fails in 0.14.4 #381

Open
anthonyz-davis opened this issue Aug 18, 2017 · 2 comments
Open

Comments

@anthonyz-davis
Copy link

anthonyz-davis commented Aug 18, 2017

We have two instances of API Umbrella running behind a load balancer, that somehow ended up running different versions. The problem is, submitting the following as a POST to api-umbrella/v1/users:

{
  "user": {
    "id": "jw6",
    "first_name": "j",
    "last_name": "w",
    "email": "[email protected]",
    "website": "www.website.com",
    "use_description": "Used for testing",
    "registration_source": "Iris backend",
    "throttle_by_ip": true,
    "roles": "",
    "enabled": "",
    "api_key": "111111",
    "api_key_hides_at": "",
    "api_key_preview": "",
    "email_verified": true,
    "registration_ip": "",
    "registration_user_agent": "",
    "registration_referer": "",
    "registration_origin": "",
    "created_at": "",
    "creator": {
      "username": "Cre"
    },
    "updated_at": "",
    "updater": {
      "username": "Up"
    },
    "terms_and_conditions": true
  }
}

succeeds in 0.14.1, but in 0.14.4 returns a 500 error, with this stack trace showing up in the logs:

2017-08-18T23:22:42.21596 Completed 500 Internal Server Error in 8ms 2017-08-18T23:22:42.21690 2017-08-18T23:22:42.21690 Mongoid::Errors::InvalidValue ( 2017-08-18T23:22:42.21690 message: 2017-08-18T23:22:42.21691 Value of type String cannot be written to a field of type Array 2017-08-18T23:22:42.21691 summary: 2017-08-18T23:22:42.21691 Tried to set a value of type String to a field of type Array 2017-08-18T23:22:42.21691 resolution: 2017-08-18T23:22:42.21691 Verify if the value to be set correspond to field definition): 2017-08-18T23:22:42.21691 lib/api_umbrella/attributify_data.rb:39:in 'assign_nested_attributes' 2017-08-18T23:22:42.21692 app/controllers/api/v1/users_controller.rb:99:in 'assign_attributes!' 2017-08-18T23:22:42.21692 app/controllers/api/v1/users_controller.rb:44:in 'create' 2017-08-18T23:22:42.21692 app/controllers/application_controller.rb:160:in 'set_userstamp' 2017-08-18T23:22:42.21693 app/controllers/application_controller.rb:88:in 'block in use_locale' 2017-08-18T23:22:42.21693 app/controllers/application_controller.rb:87:in 'use_locale'

Has a bug been introduced? Has there been some other change that requires a different model? Obviously I can't solve this by upgrading the older installation.

@anthonyz-davis anthonyz-davis changed the title POST to api-umbrella/v1/users succeeds in 0.14.1 but fails in 01.4.4 POST to api-umbrella/v1/users succeeds in 0.14.1 but fails in 0.14.4 Aug 25, 2017
@GUI
Copy link
Member

GUI commented Oct 13, 2017

@anthonyz-davis: Apologies for the delay, but thanks for reporting this. I believe this was actually due to a bug that was present in v0.14.0-0.14.1, but was fixed in v0.14.2. Specifically, there was a regression in array handling introduced in v0.14.0 that we later fixed: #367 (comment)

So I'm guessing the issue here is that the POST is sending "roles": "",, which is causing this problem, since roles should either be null or an array (but not a string itself). So we probably need to add some extra validations around that to handle this error more gracefully, but I think that type mismatch is what's triggering this error.

Are you making this POST yourself? If so, I think if you change the roles to send in an array or null, it should resolve the problem. Or if the problem was coming from the requests the v0.14.1 version of API Umbrella was making itself from the admin, then I think that should be resolved by upgrading to the latest version.

@deligence-dharmendra
Copy link

deligence-dharmendra commented Dec 28, 2017

Hi @GUI
I need help for regenerate API key for existing user using rest API call.
OR there is any other way to delete user profile using rest API call.

Please advice
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants