Details
-
Improvement
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
Description
Change the message of a function call type mismatch to read:
The function 'xxx' was called with arguments it does not accept. It expects one of:
|
as that provides the missing pieces to a user enabling them to understand where to look for the problem and what the possibly long output of type mismatches mean.
ORIGINAL
Basic Info
Puppet Version:
2016.5
OS Name/Version:
RHEL 06
Describe your issue in as much detail as possible...
when lookup function is given a none capitalized type the error message is large, confusing and misleading, which makes discovering the issue difficult for new users.
$var = lookup('var',boolean,'first',true) #incorrect
#$var = lookup('var',Boolean,'first',true) #correct
the simple lower case 'B' in boolean triggered 4 error messages for one subject, and all of them are misleading!
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, 'lookup' expects one of:
|
(NameType = Variant[String, Array[String]] name, ValueType = Type value_type?, MergeType = Variant[String[1, default], Hash[String, Scalar]] merge?)
|
rejected: expects between 1 and 3 arguments, got 4
|
(NameType = Variant[String, Array[String]] name, Optional[ValueType] value_type, Optional[MergeType] merge, DefaultValueType = Any default_value)
|
rejected: parameter 'value_type' expects a ValueType = Type value, got String
|
(NameType = Variant[String, Array[String]] name, ValueType = Type value_type?, MergeType = Variant[String[1, default], Hash[String, Scalar]] merge?)
|
rejected: expects between 1 and 3 arguments, got 4
|
(OptionsWithName = Struct[{'name' => NameType = Variant[String, Array[String]], 'value_type' => Optional[ValueType = Type], 'default_value' => DefaultValueType = Any, 'override' => Optional[Hash[String, Any]], 'default_values_hash' => Optional[Hash[String, Any]], 'merge' => Optional[MergeType = Variant[String[1, default], Hash[String, Scalar]]]}] options_hash, BlockType = Callable[NameType = Variant[String, Array[String]]] block?)
|
rejected: expects 1 argument, got 4
|
(Variant[String, Array[String]] name, OptionsWithoutName = Struct[{'value_type' => Optional[ValueType = Type], 'default_value' => DefaultValueType = Any, 'override' => Optional[Hash[String, Any]], 'default_values_hash' => Optional[Hash[String, Any]], 'merge' => Optional[MergeType = Variant[String[1, default], Hash[String, Scalar]]]}] options_hash, BlockType = Callable[NameType = Variant[String, Array[String]]] block?)
|
rejected: expects 2 arguments, got 4 at /path/to/manifest.pp:21:37 on node
|
Desired Behavior:
Output:
Error: Optional[ValueType = Type] provided must be one of [X,Y,Z]
or as at the command line
puppet lookup message --type=string
Error: Could not run: The expression <string> is not a valid type specification.
Actual Behavior:
see above.