Bug #7764
closedonly generation of JSON objects or arrays allowed
Added by Spencer Owen about 10 years ago. Updated over 6 years ago.
Description
If you attempt to create a smart parameter on a brand new install of foreman 1.6 on cent 6.5, you will get the following error.
only generation of JSON objects or arrays allowed
I've attached screenshots.
Steps to reproduce:
- Add the puppetlabs ntp module
- Add a smart parameter to override the 'servers' parameter with a value like 'time2.google.com'
- Change the prameter type from string to array
- Click apply
I'm happy to provide any additional information.
Files
Screenshot 2014-10-01 11.19.33.png | View Screenshot 2014-10-01 11.19.33.png | 123 KB | Spencer Owen, 10/01/2014 01:23 PM | ||
Screenshot 2014-10-01 11.19.43.png | View Screenshot 2014-10-01 11.19.43.png | 36.3 KB | Spencer Owen, 10/01/2014 01:23 PM | ||
production_cleansed.log | production_cleansed.log | 157 KB | Spencer Owen, 10/01/2014 01:42 PM | ||
Screenshot 2014-10-01 11.34.55.png | View Screenshot 2014-10-01 11.34.55.png | 77 KB | Spencer Owen, 10/01/2014 01:45 PM | ||
Screenshot 2014-10-01 11.43.46.png | View Screenshot 2014-10-01 11.43.46.png | 72.7 KB | Spencer Owen, 10/01/2014 01:45 PM |
Updated by Spencer Owen about 10 years ago
- File production_cleansed.log production_cleansed.log added
- File Screenshot 2014-10-01 11.34.55.png Screenshot 2014-10-01 11.34.55.png added
- File Screenshot 2014-10-01 11.43.46.png Screenshot 2014-10-01 11.43.46.png added
Full trace
I've also tried setting this as an array. (See screenshot), however it gives the same error.
JSON::GeneratorError only generation of JSON objects or arrays allowed app/models/lookup_key.rb:125:in `value_before_type_cast' app/models/lookup_key.rb:119:in `default_value_before_type_cast' app/views/lookup_keys/_fields.html.erb:17:in `_app_views_lookup_keys__fields_html_erb___1529588934913538750_77196500' app/views/puppetclasses/_form.html.erb:55:in `block (2 levels) in _app_views_puppetclasses__form_html_erb___2785295828738098368_41843320' app/views/puppetclasses/_form.html.erb:54:in `block in _app_views_puppetclasses__form_html_erb___2785295828738098368_41843320' app/helpers/layout_helper.rb:257:in `form_for' app/views/puppetclasses/_form.html.erb:3:in `_app_views_puppetclasses__form_html_erb___2785295828738098368_41843320' app/views/puppetclasses/edit.html.erb:3:in `_app_views_puppetclasses_edit_html_erb___3029618563862301220_71364300' app/controllers/application_controller.rb:293:in `process_error' app/controllers/puppetclasses_controller.rb:35:in `update' app/models/concerns/foreman/thread_session.rb:33:in `clear_thread' lib/middleware/catch_json_parse_errors.rb:9:in `call'
If I look at just the 'servers' parameter, it appears to reset back to the incorrect 'string' value every time I try and change it. (see screenshot 2014-10-01 11.43.46 where type is 'string')
Updated by Spencer Owen about 10 years ago
I was able to work around the issue by completly deleting the 'servers' paramter from the foreman.
I then uninstalled and reinstalled the module, which appears to have reset all the parameters back to defaults.
This still is a bug, the foreman shouldn't have let me put invalid parameters in, or atleast should have let me undo my mistake, not crash.
Updated by Raul Laansoo almost 10 years ago
Spencer Owen wrote:
I was able to work around the issue by completly deleting the 'servers' paramter from the foreman.
I then uninstalled and reinstalled the module, which appears to have reset all the parameters back to defaults.
This still is a bug, the foreman shouldn't have let me put invalid parameters in, or atleast should have let me undo my mistake, not crash.
Stumbled on the same issue. Fix for me was to provide default value for the type. For example for arrays you should enter []
for empty array. Maybe when changing type Foreman should also provide default 'empty' value for non-string types?
Updated by Corey Osman almost 10 years ago
Just hit this bug as well. Unable to work around this issue because I am using the use puppet default feature which greys out the default value.
I have noticed this when the parameter value in the puppet code is set to an inherited value like $class::params::value1. Foreman thinks this is a string but it should be rendered as a variable which could be any type. Currently there is no way for foreman to check the type of the inherited value so it gives up and sets it to a string.
Updated by Corey Osman almost 10 years ago
Corey Osman wrote:
Just hit this bug as well. Unable to work around this issue because I am using the use puppet default feature which greys out the default value.
I have noticed this when the parameter value in the puppet code is set to an inherited value like $class::params::value1. Foreman thinks this is a string but it should be rendered as a variable which could be any type. Currently there is no way for foreman to check the type of the inherited value so it gives up and sets it to a string.
Actually, the work around for anyone also using the "use puppet default" feature is to do the following:
1. click override
2. keep use puppet default UNCHECKED
3. change the default value to a default value you want. Example for Array: [], Example for Hash: {}
4. change the parameter type to match your default value array = [], hash = {}
5. click submit
6. Go back and edit, and then check use puppet default (only if you desire this setting)
7. click submit (again)
Updated by The Foreman Bot almost 10 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/2195 added
- Pull request deleted (
)
Updated by Dominic Cleal almost 10 years ago
- Status changed from Ready For Testing to New
- Pull request added
- Pull request deleted (
https://github.com/theforeman/foreman/pull/2195)
PR was closed.
Updated by The Foreman Bot almost 10 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/2202 added
- Pull request deleted (
)
Updated by Shlomi Zadok almost 10 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 8dcb01a429e88a12edd605672e6f4340de7ca977.
Updated by Marek Hulán almost 10 years ago
- Related to Refactor #9553: remove dump_in_quirks_mode added
Updated by Dominic Cleal almost 10 years ago
- Assignee set to Shlomi Zadok
- Translation missing: en.field_release set to 28