Bug #17087

Updating default_value of a hash/array smart class parameter with a non string value should return an error message

Added by Ori Rabin about 1 year ago. Updated 7 months ago.

Status:Closed
Priority:Normal
Assigned To:Ori Rabin
Category:Smart Variables
Target version:Team Ivan Iteration 16
Difficulty: Bugzilla link:1411069
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4137
Story points-
Velocity based estimate-
Release1.16.0Release relationshipAuto

Description

Sending default_value as a hash/array fails through the api but doesn't give any error message.
Sending:

"default_value": "['a','b']" 

will work but
"default_value": ['a','b']

will fail with no error message

Associated revisions

Revision cade5cc2
Added by Ori Rabin 7 months ago

Fixes #17087 - default and overrides values converted to string

History

#1 Updated by Dominic Cleal about 1 year ago

default_value is defined as taking a string input in the API, the user shouldn't really be passing non-string values (arrays, hashes, ints, bools). It should probably be a string representation matching the UI. Or is some conversion happening prior to it reaching the model?

(Logs showing the issue may make this clearer.)

#2 Updated by Tomáš Strachota about 1 year ago

I agree that when it's defined as string, it should take only strings. Better error message would be appreciated though, but I'd prefer to handle it as a generic issue for the whole api.

#3 Updated by Ori Rabin about 1 year ago

  • Subject changed from Updating default_value of a hash/array smart class parameter fails in the api to Updating default_value of a hash/array smart class parameter with a non string value should return an error message
  • Description updated (diff)

#4 Updated by Ori Rabin about 1 year ago

I updated the description.
I agree with Tomas, Setting does allow to send an array as a value so this needs an error message or to change.

#5 Updated by The Foreman Bot about 1 year ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Ori Rabin
  • Pull request https://github.com/theforeman/foreman/pull/4137 added

#6 Updated by Ori Rabin about 1 year ago

  • Target version set to Team Ivan Iteration 8

#7 Updated by Ori Rabin about 1 year ago

  • Bugzilla link set to 1411069

#8 Updated by Vincent Lamers about 1 year ago

I'm running foreman 1.13.3-1. I'm having issues with overriding hashes (smart class parameter).. Yaml looks good but after I change the environment of the host I'll get a error 'value is invalid hash'. That happens to all the hashes which I want to override. It only happens after I try to change the environment of a host. Is this bug related to this? Many thanks!

#9 Updated by Ori Rabin about 1 year ago

Is your update through the api or UI? this bug is an api bug so if you're updating through the UI it's not related.
If it is unrelated please open a new issue with a description of steps and if possible attach screenshots or examples of the values.

#10 Updated by Vincent Lamers about 1 year ago

thanks. It's indeed GUI related.
I'll open an new ticket.

#11 Updated by Ori Rabin 7 months ago

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

#12 Updated by Marek Hulán 7 months ago

  • Release set to 1.16.0

#13 Updated by Ivan Necas 7 months ago

  • Target version changed from Team Ivan Iteration 8 to Team Ivan Iteration 16

Also available in: Atom PDF