Actions
Bug #4568
closedundefined method `keys' for "5":String when setting associations incorrectly
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Description
PUT /api/v2/subnets/1 {"domains":["5"]}
returns this error:
{"error": {"message":"undefined method `keys' for \"5\":String"}}
Which is correct, as the correct format is:
{"domains":[{"id":"5"}]}
But it's not a user-friendly error message. Better yet would be if it could simply accept this format with IDs or names.
Stack trace:
undefined method `keys' for "5":String (NoMethodError) /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `block (2 levels) in setup_has_many_params' /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `each' /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `all?' /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:64:in `block in setup_has_many_params' /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:60:in `each' /home/dcleal/code/foreman/foreman/app/controllers/api/v2/base_controller.rb:60:in `setup_has_many_params'
Updated by Leos Stejskal about 3 years ago
- Status changed from New to Closed
I'm closing the issue,
It has been here for some time and I wasn't able to reproduce it on the latest version.
If you think that the issue is still relevant feel free to reopen it.
Actions