Bug 1558926 - Some expression method definitions can fail with "<Script error>" in a dialog and a stack trace in evm.log
Summary: Some expression method definitions can fail with "<Script error>" in a dialog...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.9.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Yuri Rudman
QA Contact: Niyaz Akhtar Ansari
URL:
Whiteboard:
Depends On:
Blocks: 1565139
TreeView+ depends on / blocked
 
Reported: 2018-03-21 10:29 UTC by Peter McGowan
Modified: 2019-02-11 14:06 UTC (History)
9 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1565139 (view as bug list)
Environment:
Last Closed: 2019-02-11 14:06:11 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Peter McGowan 2018-03-21 10:29:42 UTC
Description of problem:
Some expression method definitions fail ungracefully; if used to populate a dynamic dialog drop-down they will display "<Script error>", and give an accompanying stack trace in evm.log, for example:

[----] E, [2018-03-21T10:11:24.239966 #2215:12c3674] ERROR -- : /var/www/miq/vmdb/lib/miq_expression.rb:1431:in `to_arel'
/var/www/miq/vmdb/lib/miq_expression.rb:289:in `to_sql'
/var/www/miq/vmdb/lib/rbac/filterer.rb:240:in `search'
/var/www/miq/vmdb/lib/rbac/filterer.rb:129:in `search'
/var/www/miq/vmdb/lib/rbac.rb:3:in `search'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_expression_method.rb:15:in `run'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb:16:in `invoke_expression'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_method.rb:74:in `invoke'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:486:in `invoke_method'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:368:in `block in process_method_raw'
/opt/rh/cfme-gemset/bundler/gems/manageiq-gems-pending-22145df40925/lib/gems/pending/util/extensions/miq-benchmark.rb:11:in `realtime_store'
/opt/rh/cfme-gemset/bundler/gems/manageiq-gems-pending-22145df40925/lib/gems/pending/util/extensions/miq-benchmark.rb:35:in `realtime_block'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:361:in `process_method_raw'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:374:in `process_method'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:315:in `block in process_filtered_fields'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:310:in `each'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:310:in `process_filtered_fields'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb:306:in `process_fields'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:149:in `instantiate'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_workspace_runtime.rb:49:in `instantiate'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine.rb:301:in `resolve_automation_object'
/opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-f11044f674db/lib/miq_automation_engine/engine/miq_ae_engine.rb:95:in `deliver'
...

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

How reproducible:
Every time

Steps to Reproduce:
1. Create an expression method with expression object: 'Vm' and expression of either 'VM and Instance.Provider : EVM Zone = "default"' or 'VM and Instance.Provider : Emstype = "rhevm"'  (I was using a RHV provider)
2. Create a dialog containing a dynamic drop-down element that calls the expression method
3. Associate the dialog with a service, and order the service

Actual results:
"<Script error>" in the drop-down

Expected results:
A drop-down list of VMs on the provider, or blank is the string used in the expression method was invalid (such as non-existant zone).

Additional info:
I have confirmed from the Rails console that the emstype is correct:

irb(main):011:0> vm=Vm.all.first
=> #<ManageIQ::Providers::Redhat::InfraManager::Vm id: 1, vendor: "redhat", format: nil, version: nil, name: "centos72-template-master", description: nil, location: "7d07a9b4-ba46-4ab1-86a6-eae505c4fca7.ovf", config_xml: nil, autostart: nil, host_id: nil, last_sync_on: nil, created_on: "2018-03-08 1...>
irb(main):012:0> vm.ext_management_system.emstype
=> "rhevm"

Some expressions work correctly, for example if I change the expression to 'VM and Instance.Provider : Type = "ManageIQ::Providers::Redhat::InfraManager"' it works fine.

Comment 2 Greg McCullough 2018-03-21 15:34:09 UTC
Peter - Have you tried using this expression elsewhere in the product?  I am thinking it is more an issue with the expression evaluation (possible due to emstype being a virtual column) then anything to do with the automate side of things.  The "type" field that does work is a direct db column.

Comment 3 Peter McGowan 2018-03-21 16:14:54 UTC
Hi Greg

The filter 'VM and Instance.Provider : Emstype = "rhevm"' seems to work fine in a report if that helps?

Comment 4 Peter McGowan 2018-03-21 16:20:55 UTC
It also works from the Advanced Search functionality of the VMs page using the search:

Virtual Machine.Provider : Emstype = "rhevm"

Comment 6 Yuri Rudman 2018-03-28 00:45:28 UTC
PR: https://github.com/ManageIQ/manageiq/pull/17215

Comment 7 Yuri Rudman 2018-03-28 13:45:54 UTC
Same bug: https://github.com/ManageIQ/manageiq/issues/16514

Comment 9 CFME Bot 2018-04-05 18:30:46 UTC
New commit detected on ManageIQ/manageiq/master:

https://github.com/ManageIQ/manageiq/commit/40ba3002f1432716a17e677e58701b675e03766a
commit 40ba3002f1432716a17e677e58701b675e03766a
Author:     Yuri Rudman <yrudman>
AuthorDate: Tue Mar 27 17:20:35 2018 -0400
Commit:     Yuri Rudman <yrudman>
CommitDate: Tue Mar 27 17:20:35 2018 -0400

    remove temporary tokens from expression hash after substitution. Keeping token will make expression evaluation failed.
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1558926

 lib/miq_expression/subst_mixin.rb | 1 +
 1 file changed, 1 insertion(+)

Comment 11 Niyaz Akhtar Ansari 2018-10-31 10:28:06 UTC
Verified in Version 5.10.0.21.20181023151612_4c11b0d


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