Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-7792

argument type mismatch message could be clearer

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 6.24.0, PUP 7.9.0
    • Component/s: None
    • Labels:
    • Template:
    • Sub-team:
    • Team:
      Coremunity
    • Sprint:
      Platform Core KANBAN
    • Release Notes:
      Enhancement
    • Release Notes Summary:
      Hide
      Puppet displays a more meaningful error message if a function is called with arguments it doesn't accept. The message now says "The function '<name>' was called with arguments it does not accept. It expects one of:" followed by the list of acceptable function signatures.
      Show
      Puppet displays a more meaningful error message if a function is called with arguments it doesn't accept. The message now says "The function '<name>' was called with arguments it does not accept. It expects one of:" followed by the list of acceptable function signatures.
    • QA Risk Assessment:
      Needs Assessment

      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.

        Attachments

          Activity

            People

            Assignee:
            josh Josh Cooper
            Reporter:
            adam.buxton Adam Buxton
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support