Bug 1829279

Summary: Custom Button: create custom button with REST API fails
Product: Red Hat CloudForms Management Engine Reporter: Nikhil Dhandre <ndhandre>
Component: APIAssignee: drew uhlmann <duhlmann>
Status: CLOSED DUPLICATE QA Contact: Nikhil Dhandre <ndhandre>
Severity: urgent Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: unspecified    
Version: 5.11.5CC: obarenbo, yrudman
Target Milestone: GAKeywords: Regression
Target Release: cfme-future   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-29 16:15:11 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:

Description Nikhil Dhandre 2020-04-29 10:35:52 UTC
Description of problem:
-----------------------
While creating custom button with rest getting 500 response

"undefined local variable or method `custom_button' for #<Api::CustomButtonsController:0x0000557605973210>"


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


How reproducible:
----------------
always


Steps to Reproduce:
-------------------

POST https://hostname/api/custom_buttons

{
	"action": "create",
	"resources": [
		{
			"applies_to_class": "CloudNetwork",
			"description": "btn_hUEvrZ",
			"name": "btn_desc_zsZ",
			"options": {
				"button_color": "#4727ff",
				"button_icon": "ff fa-user",
				"display": true
			},
			"resource_action": {
				"ae_class": "PROCESS",
				"ae_namespace": "SYSTEM"
			}
		},
		{
			"applies_to_class": "CloudNetwork",
			"description": "btn_3lmjXr",
			"name": "btn_desc_d3q",
			"options": {
				"button_color": "#4727ff",
				"button_icon": "ff fa-user",
				"display": true
			},
			"resource_action": {
				"ae_class": "PROCESS",
				"ae_namespace": "SYSTEM"
			}
		}
	]
}


Actual results:
---------------
500 responce code with error

{
  "error": {
    "kind": "internal_server_error",
    "message": "undefined local variable or method `custom_button' for #<Api::CustomButtonsController:0x0000557605973210>",
    "klass": "NameError"
  }
}


Expected results:
-----------------
It should work

Additional info:
----------------
This functionality working fine with 5.10 and 5.11.4.2. Marking as regration.

Comment 3 drew uhlmann 2020-04-29 14:52:57 UTC
Hey Nikhil, please include stack traces if you can. 

Error caught: [NameError] undefined local variable or method `custom_button' for #<Api::CustomButtonsController:0x00007ff9c06d0af8>
/Users/drewmu/manageiq-api/app/controllers/api/custom_buttons_controller.rb:14:in `rescue in create_resource'
/Users/drewmu/manageiq-api/app/controllers/api/custom_buttons_controller.rb:3:in `create_resource'
/Users/drewmu/manageiq-api/app/controllers/api/base_controller.rb:76:in `block in create'
/Users/drewmu/manageiq-api/app/controllers/api/base_controller.rb:66:in `collect'
/Users/drewmu/manageiq-api/app/controllers/api/base_controller.rb:66:in `create'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/abstract_controller/base.rb:186:in `process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activesupport-5.1.7/lib/active_support/callbacks.rb:131:in `run_callbacks'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/abstract_controller/callbacks.rb:19:in `process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/action_controller/metal/rescue.rb:20:in `process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `block in instrument'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activesupport-5.1.7/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activesupport-5.1.7/lib/active_support/notifications.rb:166:in `instrument'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/actionpack-5.1.7/lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
/Users/drewmu/.rvm/gems/ruby-2.5.5/gems/activerecord-5.1.7/lib/active_record/railties/controller_runtime.rb:22:in `process_action'

Comment 4 drew uhlmann 2020-04-29 14:55:09 UTC
Dup of https://bugzilla.redhat.com/show_bug.cgi?id=1827818

Comment 6 drew uhlmann 2020-04-29 16:15:11 UTC
thanks! closing though.

*** This bug has been marked as a duplicate of bug 1827818 ***