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.
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.
Hi Greg The filter 'VM and Instance.Provider : Emstype = "rhevm"' seems to work fine in a report if that helps?
It also works from the Advanced Search functionality of the VMs page using the search: Virtual Machine.Provider : Emstype = "rhevm"
PR: https://github.com/ManageIQ/manageiq/pull/17215
Same bug: https://github.com/ManageIQ/manageiq/issues/16514
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(+)
Verified in Version 5.10.0.21.20181023151612_4c11b0d