Bug 1549086

Summary: internal server error ActiveRecord::AssociationTypeMismatch when editing current_group
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kourim <mkourim>
Severity: high Docs Contact:
Priority: high    
Version: 5.9.0CC: cpelland, gtanzill, obarenbo
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: api:rest
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1551692 1551693 (view as bug list) Environment:
Last Closed: 2018-07-30 14:43:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1551692, 1551693    

Description Martin Kourim 2018-02-26 11:27:36 UTC
Description of problem:
When editing the "current_group" the request fails with:
{
	"error": {
		"kind": "internal_server_error",
		"message": "MiqGroup(#14516000) expected, got Hash(#4780420)",
		"klass": "ActiveRecord::AssociationTypeMismatch"
	}
}

Might be related to https://bugzilla.redhat.com/show_bug.cgi?id=1549085 , only this one happens on both 5.9.0 and 5.8.4

Version-Release number of selected component (if applicable):
5.8.3.4
5.9.0.22


How reproducible:
100%


Steps to Reproduce:
1. create a user
2. POST /api/users/:id
{
    "action": "edit",
    "current_group": {"href": "https://addr/api/groups/13"}
}

Comment 3 CFME Bot 2018-02-27 14:30:46 UTC
New commit detected on ManageIQ/manageiq-api/master:
https://github.com/ManageIQ/manageiq-api/commit/d2e8ea4a43978d95db19af67c0854340e703fb27

commit d2e8ea4a43978d95db19af67c0854340e703fb27
Author:     Jillian Tullo <jtullo>
AuthorDate: Tue Feb 27 08:45:30 2018 -0500
Commit:     Jillian Tullo <jtullo>
CommitDate: Tue Feb 27 08:45:30 2018 -0500

    Raise bad request when current_group is specified on edit
    
    Editing of a current_group is allowed only on on the set_current_group action.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1549086

 app/controllers/api/users_controller.rb |  4 ++--
 spec/requests/users_spec.rb             | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

Comment 7 Dave Johnson 2018-07-30 14:43:41 UTC
Closing this as its already been verified in two z-streams and has test coverage around it.