Bug 1672358 - [RFE] Unable to create Service Template via the API
Summary: [RFE] Unable to create Service Template via the API
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Provisioning
Version: 5.9.6
Hardware: All
OS: All
high
high
Target Milestone: GA
: 5.11.8
Assignee: drew uhlmann
QA Contact: Parthvi Vala
Red Hat CloudForms Documentation
URL:
Whiteboard:
: 1854173 (view as bug list)
Depends On:
Blocks: 1822318
TreeView+ depends on / blocked
 
Reported: 2019-02-04 17:38 UTC by Ryan Spagnola
Modified: 2023-09-07 19:42 UTC (History)
13 users (show)

Fixed In Version: 5.11.8.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-09-30 14:01:06 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:
simaishi: cfme-5.11.z+


Attachments (Terms of Use)

Description Ryan Spagnola 2019-02-04 17:38:34 UTC
Description of problem:
Following the documentation found here: https://access.redhat.com/documentation/en-us/red_hat_cloudforms/4.6/html/red_hat_cloudforms_rest_api/chap_examples#create-service-template , I am still unable to create a service template via the API. Upon POST, I get the error:

{"error":{"kind":"bad_request","message":"Could not create Service Template - undefined method `base_class' for FalseClass:Class","klass":"Api::BadRequestError"}}

Version-Release number of selected component (if applicable):
Customer tested this in 5.9.5.3, 5.9.6.5, and the manageiq upstream vagrant gaprindashvili-7

How reproducible:
Always

Steps to Reproduce:
1. Running the curl command in customer environment produces the error
2.
3.

Actual results:


Expected results:


Additional info:

Comment 4 Joe Rafaniello 2019-02-05 21:54:13 UTC
Ryan, I was unable to recreate this on the tip of gaprindashvili, note, I'm using my database that would have different dialogs, templates, etc.

Since a "undefined method" error is treated as a "internal server error", the backtrace should be logged in the vmdb/log/api.log.

Please request the logs after hitting this error, and if that log shows nothing, please see if they can recreate in a test environment and provide a db export so we can recreate it here.

Thanks!
joe

Comment 8 Joe Rafaniello 2019-02-07 16:37:20 UTC
I was wrong, this is treated as a bad request error and therefore the backtrace is not printed.

I had to comment out the if conditional here:

https://github.com/ManageIQ/manageiq-api/blob/e75c9e08e7ccfe9dbd5c2b687303b6d981d4fd03/app/controllers/api/base_controller.rb#L190

api_log_error("\n\n#{error.backtrace.join("\n")}") #if type == :internal_server_error && !error.backtrace.empty?

Here's the backtrace:

[----] E, [2019-02-07T11:34:52.039170 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) API Error
[----] E, [2019-02-07T11:34:52.039308 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) Api::BadRequestError: Could not create Service Template - undefined method `base_class' for FalseClass:Class
[----] E, [2019-02-07T11:34:52.039511 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) API Error
[----] E, [2019-02-07T11:34:52.039593 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error)
[----] E, [2019-02-07T11:34:52.040186 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error)
[----] E, [2019-02-07T11:34:52.040241 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/service_templates_controller.rb:19:in `rescue in create_resource'
[----] E, [2019-02-07T11:34:52.040295 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/service_templates_controller.rb:15:in `create_resource'
[----] E, [2019-02-07T11:34:52.040352 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/base_controller.rb:77:in `block in create'
[----] E, [2019-02-07T11:34:52.040405 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/base_controller.rb:67:in `collect'
[----] E, [2019-02-07T11:34:52.040457 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/base_controller.rb:67:in `create'
[----] E, [2019-02-07T11:34:52.040514 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
[----] E, [2019-02-07T11:34:52.040579 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/abstract_controller/base.rb:188:in `process_action'
[----] E, [2019-02-07T11:34:52.040633 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/rendering.rb:30:in `process_action'
[----] E, [2019-02-07T11:34:52.040684 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
[----] E, [2019-02-07T11:34:52.040737 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:126:in `call'
[----] E, [2019-02-07T11:34:52.040789 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
[----] E, [2019-02-07T11:34:52.040840 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:455:in `call'
[----] E, [2019-02-07T11:34:52.040892 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
[----] E, [2019-02-07T11:34:52.040944 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
[----] E, [2019-02-07T11:34:52.040995 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:90:in `run_callbacks'
[----] E, [2019-02-07T11:34:52.041047 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/abstract_controller/callbacks.rb:19:in `process_action'
[----] E, [2019-02-07T11:34:52.041112 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/rescue.rb:20:in `process_action'
[----] E, [2019-02-07T11:34:52.041172 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
[----] E, [2019-02-07T11:34:52.041744 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/notifications.rb:164:in `block in instrument'
[----] E, [2019-02-07T11:34:52.041799 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
[----] E, [2019-02-07T11:34:52.041851 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/notifications.rb:164:in `instrument'
[----] E, [2019-02-07T11:34:52.041903 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
[----] E, [2019-02-07T11:34:52.041955 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
[----] E, [2019-02-07T11:34:52.042007 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
[----] E, [2019-02-07T11:34:52.042065 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/abstract_controller/base.rb:126:in `process'
[----] E, [2019-02-07T11:34:52.042141 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal.rb:190:in `dispatch'
[----] E, [2019-02-07T11:34:52.042203 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal.rb:262:in `dispatch'
[----] E, [2019-02-07T11:34:52.042255 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
[----] E, [2019-02-07T11:34:52.042307 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/routing/route_set.rb:32:in `serve'
[----] E, [2019-02-07T11:34:52.042359 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>'
[----] E, [2019-02-07T11:34:52.042410 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/routing/mapper.rb:46:in `serve'
[----] E, [2019-02-07T11:34:52.042462 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/journey/router.rb:39:in `block in serve'
[----] E, [2019-02-07T11:34:52.042514 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/journey/router.rb:26:in `each'
[----] E, [2019-02-07T11:34:52.042566 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/journey/router.rb:26:in `serve'
[----] E, [2019-02-07T11:34:52.042618 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/routing/route_set.rb:727:in `call'
[----] E, [2019-02-07T11:34:52.042670 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/secure_headers-3.0.3/lib/secure_headers/middleware.rb:10:in `call'
[----] E, [2019-02-07T11:34:52.042721 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/etag.rb:25:in `call'
[----] E, [2019-02-07T11:34:52.042772 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/conditional_get.rb:38:in `call'
[----] E, [2019-02-07T11:34:52.043411 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/head.rb:12:in `call'
[----] E, [2019-02-07T11:34:52.043464 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/session/abstract/id.rb:232:in `context'
[----] E, [2019-02-07T11:34:52.043516 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/session/abstract/id.rb:226:in `call'
[----] E, [2019-02-07T11:34:52.043569 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/cookies.rb:613:in `call'
[----] E, [2019-02-07T11:34:52.043620 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
[----] E, [2019-02-07T11:34:52.043672 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
[----] E, [2019-02-07T11:34:52.043724 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
[----] E, [2019-02-07T11:34:52.043786 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/callbacks.rb:90:in `run_callbacks'
[----] E, [2019-02-07T11:34:52.043840 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
[----] E, [2019-02-07T11:34:52.043892 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
[----] E, [2019-02-07T11:34:52.043945 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
[----] E, [2019-02-07T11:34:52.043997 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
[----] E, [2019-02-07T11:34:52.044049 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/rack/logger.rb:36:in `call_app'
[----] E, [2019-02-07T11:34:52.044114 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/rack/logger.rb:26:in `call'
[----] E, [2019-02-07T11:34:52.044174 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/request_id.rb:24:in `call'
[----] E, [2019-02-07T11:34:52.044227 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/method_override.rb:22:in `call'
[----] E, [2019-02-07T11:34:52.044288 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/runtime.rb:22:in `call'
[----] E, [2019-02-07T11:34:52.044346 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/activesupport-5.0.6/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
[----] E, [2019-02-07T11:34:52.044398 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
[----] E, [2019-02-07T11:34:52.044967 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/rack-2.0.3/lib/rack/sendfile.rb:111:in `call'
[----] E, [2019-02-07T11:34:52.045021 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/engine.rb:522:in `call'
[----] E, [2019-02-07T11:34:52.045083 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.7.1/lib/puma/configuration.rb:232:in `call'
[----] E, [2019-02-07T11:34:52.045143 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.7.1/lib/puma/server.rb:578:in `handle_request'
[----] E, [2019-02-07T11:34:52.045217 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.7.1/lib/puma/server.rb:415:in `process_client'
[----] E, [2019-02-07T11:34:52.045292 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.7.1/lib/puma/server.rb:275:in `block in run'
[----] E, [2019-02-07T11:34:52.045359 #14454:151ef54] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) /opt/rh/rh-ruby23/root/usr/share/gems/gems/puma-3.7.1/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Comment 9 Joe Rafaniello 2019-02-07 16:55:49 UTC
If I now remove the logging I added in comment #8, and instead put the logging where it's blowing up originally (from the backtrace in comment #8)
/opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/service_templates_controller.rb:19:in `rescue in create_resource'


    def create_resource(_type, _id, data)
      catalog_item_type = ServiceTemplate.class_from_request_data(data)
      catalog_item_type.create_catalog_item(data.deep_symbolize_keys, User.current_user.userid)
    rescue => err
api_log_error("Error: #{err}")
api_log_error("\n\n#{err.backtrace.join("\n")}")
      raise BadRequestError, "Could not create Service Template - #{err}"
    end

I now get the actual error:

Something is passing a false "resource" into add_resource.


[----] E, [2019-02-07T11:42:42.080516 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) API Error
[----] E, [2019-02-07T11:42:42.080653 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) Error: undefined method `base_class' for FalseClass:Class
[----] E, [2019-02-07T11:42:42.080799 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) API Error
[----] E, [2019-02-07T11:42:42.080873 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource)
[----] E, [2019-02-07T11:42:42.080925 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource)
[----] E, [2019-02-07T11:42:42.080990 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /var/www/miq/vmdb/app/models/mixins/service_mixin.rb:17:in `add_resource'
[----] E, [2019-02-07T11:42:42.081043 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /var/www/miq/vmdb/app/models/service_template.rb:462:in `add_resource'
[----] E, [2019-02-07T11:42:42.081095 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /var/www/miq/vmdb/app/models/service_template.rb:104:in `block (2 levels) in create_catalog_item'
[----] E, [2019-02-07T11:42:42.081146 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /var/www/miq/vmdb/app/models/service_template.rb:98:in `tap'
[----] E, [2019-02-07T11:42:42.081205 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /var/www/miq/vmdb/app/models/service_template.rb:98:in `block in create_catalog_item'
[----] E, [2019-02-07T11:42:42.081256 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
[----] E, [2019-02-07T11:42:42.081312 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
[----] E, [2019-02-07T11:42:42.081364 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
[----] E, [2019-02-07T11:42:42.081414 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/activerecord-5.0.6/lib/active_record/transactions.rb:211:in `transaction'
[----] E, [2019-02-07T11:42:42.081465 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /var/www/miq/vmdb/app/models/service_template.rb:97:in `create_catalog_item'
[----] E, [2019-02-07T11:42:42.081517 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/service_templates_controller.rb:17:in `create_resource'
[----] E, [2019-02-07T11:42:42.081568 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/base_controller.rb:77:in `block in create'
[----] E, [2019-02-07T11:42:42.081619 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/base_controller.rb:67:in `collect'
[----] E, [2019-02-07T11:42:42.081670 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/bundler/gems/cfme-api-092b128a81f9/app/controllers/api/base_controller.rb:67:in `create'
[----] E, [2019-02-07T11:42:42.081734 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
[----] E, [2019-02-07T11:42:42.081787 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/abstract_controller/base.rb:188:in `process_action'
[----] E, [2019-02-07T11:42:42.081838 #4964:15d53bc] ERROR -- : MIQ(Api::ServiceTemplatesController.rescue in create_resource) /opt/rh/cfme-gemset/gems/actionpack-5.0.6/lib/action_controller/metal/rendering.rb:30:in `process_action'

Comment 11 Joe Rafaniello 2019-02-08 00:02:57 UTC
Ryan, see my last update.  From my testing on your recreation environment, it looks it's failing validation of the request workflow on required but not provided catalog/provision type and network/virtual network parameters.  I'm asking for people more familiar with the provisioning and request workflows to take a look.  There's a few problems:

1) We're losing the reason for the validation failures, so the api only can return "bad request"
2) The validation failures don't match the documentation

It's unclear if the customer environment has changes to the dialogs/service templates to cause this extra validation that's not in the example.

Comment 14 Joe Rafaniello 2019-02-12 19:04:38 UTC
Ryan, I'm not well versed in workflow validations or dialogs/templates but I mentioned the service template provision seemed to be failing for the missing "provision type" and "network" information in comment #10 and comment #11. I will need help from others on my team who are more knowledgeable with service template/workflows to understand if these required fields are being required in custom provisioning dialogs or something we're doing internally.  Either way, we need to log when we validate workflow options and something fails validation instead of silently returning "bad request" in the API.  It would be great if we raised an error that the API could then return to the user with what exactly was missing in their API request.

Comment 15 drew uhlmann 2019-02-13 19:24:24 UTC
I'm looking at this.

Comment 16 drew uhlmann 2019-02-14 15:27:00 UTC
I don't believe this is supported for vmware. Creating service templates is exposed on the API today to work with the necessary javascript components for embedded ansible services. This could be a request for feature enhancement but we know this functionality isn't supported for all service template types today. There's potentially a doc update required for the fact that this is only supported for various types.

Comment 17 Tina Fitzgerald 2019-02-18 19:21:20 UTC
Hi Loic,

Changed to an RFE based on Comment 16.

Thanks,
Tina

Comment 20 Satoe Imaishi 2020-08-19 15:01:38 UTC
From https://bugzilla.redhat.com/show_bug.cgi?id=1854173#c3 and https://bugzilla.redhat.com/show_bug.cgi?id=1854173#c4

The PR to fix this is here: https://github.com/ManageIQ/manageiq/pull/20319 
https://github.com/ManageIQ/manageiq-api/pull/860 should also be counted as a PR that, while it won't fix this and is not intended to do so, will clarify the error. 

Per that PR, here are the errors associated with this ticket. 
Could not create Service Template - Service Model not found and
Could not create Service Template - Unable to launch Automate Method because currently in SQL transaction

Additional info:
https://github.com/ManageIQ/manageiq-api/issues/823

Comment 21 Satoe Imaishi 2020-08-19 15:02:11 UTC
*** Bug 1854173 has been marked as a duplicate of this bug. ***

Comment 22 CFME Bot 2020-08-19 15:20:38 UTC
New commit detected on ManageIQ/manageiq/ivanchuk:

https://github.com/ManageIQ/manageiq/commit/4a04ebb5a86020cd3ffd823e840980abc55ca0b9
commit 4a04ebb5a86020cd3ffd823e840980abc55ca0b9
Author:     Greg McCullough <gmccullo>
AuthorDate: Thu Jul  9 19:51:59 2020 +0000
Commit:     Satoe Imaishi <simaishi>
CommitDate: Wed Aug 19 15:05:07 2020 +0000

    Merge pull request #20319 from d-m-u/prevent_vm_naming_from_service_template_create

    add a request template subclass post-create in miq_request_workflow

    (cherry picked from commit d67c05fd7f52e3e98c537c22891114473214ed98)

    https://bugzilla.redhat.com/show_bug.cgi?id=1672358

 app/models/miq_provision_request_template.rb | 5 +
 spec/models/miq_provision_request_template_spec.rb | 10 +
 2 files changed, 15 insertions(+)

Comment 23 CFME Bot 2020-08-19 15:26:40 UTC
New commit detected on ManageIQ/manageiq-api/ivanchuk:

https://github.com/ManageIQ/manageiq-api/commit/0ab34a3acc78595827f563e5cec99fecbe0da01b
commit 0ab34a3acc78595827f563e5cec99fecbe0da01b
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Jul  6 14:09:19 2020 +0000
Commit:     Satoe Imaishi <simaishi>
CommitDate: Wed Aug 19 15:21:41 2020 +0000

    Merge pull request #860 from d-m-u/add_trace_to_service_template_failed_create

    add trace for easier debugging from failed service template create

    (cherry picked from commit d029f3fd90c0f597b80e5206d3d93010bb3b0f56)

    https://bugzilla.redhat.com/show_bug.cgi?id=1672358

 app/controllers/api/service_templates_controller.rb | 1 +
 1 file changed, 1 insertion(+)

Comment 25 Parthvi Vala 2020-09-15 11:41:55 UTC
Verified on 5.11.8.0.

Can see error in the api.log when creating service template with vmware and generic_ansible_playbook prov_type. Still not possible to create service template of type other than generic.
I see the following errors in api logs.
[----] E, [2020-09-15T07:04:53.269113 #6862:2b25e5fb7d64] ERROR -- : Service template create failed with undefined method `key?' for nil:NilClass at /var/www/miq/vmdb/app/models/service_template_ansible_playbook.rb:59:in `validate_config_info'
[----] E, [2020-09-15T07:04:53.269782 #6862:2b25e5fb7d64] ERROR -- : MIQ(Api::ServiceTemplatesController.api_error) Api::BadRequestError: Could not create Service Template - undefined method `key?' for nil:NilClass

Comment 30 errata-xmlrpc 2020-09-30 14:01:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: CloudForms 5.0.8 security, bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:4134


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