Project

General

Profile

Bug #7764

only generation of JSON objects or arrays allowed

Added by Spencer Owen almost 6 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Parameters
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

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.


Related issues

Related to Foreman - Refactor #9553: remove dump_in_quirks_modeClosed2015-02-25

Associated revisions

Revision 8dcb01a4 (diff)
Added by Shlomi Zadok over 5 years ago

fixes #7764 - add quirks mode to JSON.dump

Revision 1d0dcc48 (diff)
Added by Shlomi Zadok over 5 years ago

fixes #7764 - add quirks mode to JSON.dump

(cherry picked from commit 8dcb01a429e88a12edd605672e6f4340de7ca977)

History

#1 Updated by Spencer Owen almost 6 years ago

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')

#2 Updated by Spencer Owen almost 6 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.

#3 Updated by Raul Laansoo over 5 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?

#4 Updated by Corey Osman over 5 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.

#5 Updated by Corey Osman over 5 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)

#6 Updated by Dominic Cleal over 5 years ago

  • Category set to Parameters

#7 Updated by The Foreman Bot over 5 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2195 added
  • Pull request deleted ()

#8 Updated by Dominic Cleal over 5 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.

#9 Updated by The Foreman Bot over 5 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/2202 added
  • Pull request deleted ()

#10 Updated by Shlomi Zadok over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#11 Updated by Marek Hulán over 5 years ago

#12 Updated by Bryan Kearney over 5 years ago

  • Bugzilla link set to 1195212

#13 Updated by Dominic Cleal over 5 years ago

  • Assignee set to Shlomi Zadok
  • Legacy Backlogs Release (now unused) set to 28

Also available in: Atom PDF