{"record":{"id":"45def4eb2bafcd28","repo":"puppetlabs/puppet","slug":"parsing-of-type-string-type-string-failed-w","errorCode":null,"errorMessage":"Parsing of type string '\"%{type_string}\"' failed with message: <%{message}>.\n","messagePattern":"Parsing of type string '\"%(.+?)\"' failed with message: <%(.+?)>\\.\n","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/functions.rb","lineNumber":595,"sourceCode":"    # Handles creation of a callable type from strings specifications of puppet\n    # types and allows the min/max occurs of the given types to be given as one\n    # or two integer values at the end.  The given block_type should be\n    # Optional[Callable], Callable, or nil.\n    #\n    # @api private\n    def create_callable(types, block_type, return_type, from, to)\n      mapped_types = types.map do |t|\n        t.is_a?(Puppet::Pops::Types::PAnyType) ? t : internal_type_parse(t, loader)\n      end\n      param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))\n      return_type = internal_type_parse(return_type, loader) unless return_type.nil? || return_type.is_a?(Puppet::Pops::Types::PAnyType)\n      Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)\n    end\n\n    def internal_type_parse(type_string, loader)\n      Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)\n    rescue StandardError => e\n      raise ArgumentError, _(\"Parsing of type string '\\\"%{type_string}\\\"' failed with message: <%{message}>.\\n\") % {\n        type_string: type_string,\n        message: e.message\n      }\n    end\n    private :internal_type_parse\n  end\n\n  # The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual\n  # type aliases given by the function's author.\n  #\n  class LocalTypeAliasesBuilder\n    attr_reader :local_types, :parser, :loader\n\n    def initialize(loader, name)\n      @loader = Puppet::Pops::Loader::PredefinedLoader.new(loader, :\"local_function_#{name}\", loader.environment)\n      @local_types = []\n      # get the shared parser used by puppet's compiler\n      @parser = Puppet::Pops::Parser::EvaluatingParser.singleton()","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/functions.rb#L577-L613","documentation":"When a dispatch signature is assembled, every String type reference is parsed with the Pops TypeParser. If parsing fails, internal_type_parse re-raises the parser's message wrapped in this ArgumentError. The error names the exact offending type string, so a typo or unbalanced bracket is easy to locate.","triggerScenarios":"param 'Strin', :s (typo), param 'Array[String', :xs (unbalanced bracket), or a self-referencing alias that the parser cannot resolve during parse. It usually surfaces nested inside 'Function Load Error' because create_function wraps it.","commonSituations":"Typos in type names; missing closing brackets after edits; using type aliases that are not in scope for the function's loader; Puppet version differences in supported type syntax.","solutions":["Copy the exact quoted type_string out of the message and fix it: check spelling against the Puppet type reference and balance all brackets.","Verify the corrected string parses: Puppet::Pops::Types::TypeParser.singleton.parse('YourType') in a console.","If the string references a local alias, make sure local_types declares it and that its own right-hand side is valid.","For third-party functions, match the module release to your Puppet version; type syntax support varies."],"exampleFix":"# before\n param 'Strin', :s\n param 'Array[String', :xs\n\n# after\n param 'String', :s\n param 'Array[String]', :xs","handlingStrategy":"validation","validationCode":"# Fail fast with your own message: pre-parse every type string used in dispatches\n%w[String Integer Array[String] Optional[Hash]].each do |t|\n  Puppet::Pops::Types::TypeParser.singleton.parse(t)\nend","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Pops::Types::TypeParser.singleton.parse(candidate_type)\nrescue StandardError => e\n  raise ArgumentError, \"fix type string '#{candidate_type}': #{e.message}\"\nend","preventionTips":["Pre-parse type strings in a console before committing function code.","Balance every bracket; check spelling against the Puppet type reference.","Keep local type aliases near the functions that use them, in local_types."],"tags":["puppet","functions","type-parser","dispatch","type-string"],"backgroundTag":"type-string-parse-error","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}