Project

General

Profile

Actions

Bug #35338

open

Using input() in a host parameters leads to `template_inputs' for nil:NilClass on hosts overview error

Added by Lucas Bickel over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

When i create a Host Parameter of type string containing a call to the input erb method, I can save the host settings but the host overview will break.

To reproduce, create a variable called test with the contents <% input('test') %>

next navigate to the hosts view and you get "undefined method `template_inputs' for nil:NilClass"

The value is stored in the db, and the only way to recover the hosts page is to fix it in the database where it is stored:

# select name,value from parameters where name = 'test';
 name |           value           
------+---------------------------
 test | --- "<% input('test') %>"+
      | 
(1 row)

# update parameters set value = '' where name = 'test';
UPDATE 1

The attached stack-trace doesn't completely match #35095 but i it to be related to this issue because it's throwing the same error.

My gut feeling is that this was introduced in https://github.com/theforeman/foreman/commit/989e0aad01df80dea8fd4734a78e794770b39f2d but that was already in 3.1.0 which wouldn't add up with my feeling that this might be related to #35095.

The root exception seems to be triggered here: https://github.com/theforeman/foreman/blob/aef76932236377f18cfecd2100576dcda577e2bf/app/services/foreman/renderer/scope/macros/inputs.rb#L37

I stumbled over this when i was trying to manage job templates using the theforeman.foreman.job_template module from FAM. I can probably find workarounds for my use-case but the fact that a wrong host variable can make the hosts list unusable feels like this warrants a bug report.


Files

host_variables.png View host_variables.png 27.6 KB Lucas Bickel, 08/06/2022 08:34 PM
oops.png View oops.png 26.5 KB Lucas Bickel, 08/06/2022 08:37 PM
error.txt error.txt 21.2 KB Lucas Bickel, 08/06/2022 08:40 PM
Actions #1

Updated by Lucas Bickel over 1 year ago

  • Subject changed from Using input() in a nested string fails in host parameters leads to `template_inputs' for nil:NilClass on hosts overview to Using input() in a host parameters leads to `template_inputs' for nil:NilClass on hosts overview error
Actions #2

Updated by Maria Agaphontzev over 1 year ago

I got the same error. I used foreman with no plugins, added this param to the host, went to host details (legacy page) -> templates tab -> preview template.
The error happened in a different function in the same file
https://github.com/theforeman/foreman/blob/aef76932236377f18cfecd2100576dcda577e2bf/app/services/foreman/renderer/scope/macros/inputs.rb#L21

Actions

Also available in: Atom PDF