{"record":{"id":"613c1c64a3703034","repo":"puppetlabs/puppet","slug":"only-string-regexp-pattern-type-and-regexp-type","errorCode":null,"errorMessage":"Only String, Regexp, Pattern-Type, and Regexp-Type are allowed: got '#{re.class}","messagePattern":"Only String, Regexp, Pattern-Type, and Regexp-Type are allowed: got '#(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/type_factory.rb","lineNumber":292,"sourceCode":"  def self.pattern(*regular_expressions)\n    patterns = regular_expressions.map do |re|\n      case re\n      when String\n        re_t = PRegexpType.new(re)\n        re_t.regexp # compile it to catch errors\n        re_t\n\n      when Regexp\n        PRegexpType.new(re)\n\n      when PRegexpType\n        re\n\n      when PPatternType\n        re.patterns\n\n      else\n        raise ArgumentError, \"Only String, Regexp, Pattern-Type, and Regexp-Type are allowed: got '#{re.class}\"\n      end\n    end.flatten.uniq\n    PPatternType.new(patterns)\n  end\n\n  # Produces the Scalar type\n  # @api public\n  #\n  def self.scalar\n    PScalarType::DEFAULT\n  end\n\n  # Produces the ScalarData type\n  # @api public\n  #\n  def self.scalar_data\n    PScalarDataType::DEFAULT\n  end","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/type_factory.rb#L274-L310","documentation":"A case-else guard in TypeFactory.pattern: the argument is not one of String, Regexp, PPatternType, or PRegexpType, so it cannot contribute a regex pattern.","triggerScenarios":"Thrown at lib/puppet/pops/types/type_factory.rb:292 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass pattern arguments as Strings, Regexp instances, or Pattern/Regexp types","Convert other objects to a Regexp or pattern String first"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","contentChangedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}