Bug 1549085 - internal server error ActiveRecord::AssociationTypeMismatch when editing miq_groups
Summary: internal server error ActiveRecord::AssociationTypeMismatch when editing miq_...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.8.0
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: GA
: 5.8.5
Assignee: Brandon Dunne
QA Contact: Martin Kourim
URL:
Whiteboard: api:rest
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-26 11:23 UTC by Martin Kourim
Modified: 2018-09-07 17:52 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-09-07 17:52:27 UTC
Category: ---
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Martin Kourim 2018-02-26 11:23:31 UTC
Description of problem:
When editing the "miq_groups" the request fails with:
{
	"error": {
		"kind": "internal_server_error",
		"message": "MiqGroup(#105333660) expected, got Hash(#11727220)",
		"klass": "ActiveRecord::AssociationTypeMismatch"
	}
}


Version-Release number of selected component (if applicable):
5.8.3.4
The same request works on 5.9.0.22.


How reproducible:
100%


Steps to Reproduce:
1. create a user
2. POST /api/users/:id
{
	"action": "edit",
	"resource": {
		"miq_groups": [
			{"href": "https://addr/api/groups/13"},
			{"href": "https://addr/api/groups/6"}
		]
	}
}
Response:
{
	"error": {
		"kind": "internal_server_error",
		"message": "MiqGroup(#105333660) expected, got Hash(#11727220)",
		"klass": "ActiveRecord::AssociationTypeMismatch"
	}
}

Comment 2 Jillian Tullo 2018-02-26 18:29:19 UTC
The reason for this issue is that on 5.8, `miq_groups` was not supported, it was added later on for the G release. In this version, only a single group is allowed, which sets the `miq_groups` to that partciular group.

In 5.8, the following editing of groups was allowed:
POST /api/users/:id
{
	"action": "edit",
	"resource": {
            "group": { "description": "group_description" }
	}
}

Also supported are id and href for a group.

However, I will fix to return an appropriate error message, unless this feature is requested in 5.8. Please let me know what approach to take.

Thank you!

Comment 3 Martin Kourim 2018-02-27 08:27:08 UTC
Thanks for clarification Jillian, I don't know of any request to support this feature in 5.8 (I just tried if it works there), appropriate error message seems good enough to me.
Also severity can be decreased.
Thank you!


Note You need to log in before you can comment on or make changes to this bug.