{"record":{"id":"d2ca543242b3750c","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-d2ca54","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Regexp type - expected one of the characters 'sp'","messagePattern":"Illegal format '#(.+?)' specified for value of Regexp type - expected one of the characters 'sp'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":938,"sourceCode":"      end\n    end\n    bld << '\"'\n    bld\n  end\n\n  # @api private\n  def string_PRegexpType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    case f.format\n    when :p\n      str_regexp = PRegexpType.regexp_to_s_with_delimiters(val)\n      f.orig_fmt == '%p' ? str_regexp : Kernel.format(f.orig_fmt.tr('p', 's'), str_regexp)\n    when :s\n      str_regexp = PRegexpType.regexp_to_s(val)\n      str_regexp = puppet_quote(str_regexp) if f.alt?\n      f.orig_fmt == '%s' ? str_regexp : Kernel.format(f.orig_fmt, str_regexp)\n    else\n      raise FormatError.new('Regexp', f.format, 'sp')\n    end\n  end\n\n  def string_PArrayType(val_type, val, format_map, indentation)\n    format         = get_format(val_type, format_map)\n    sep            = format.separator || DEFAULT_ARRAY_FORMAT.separator\n    string_formats = format.container_string_formats || DEFAULT_CONTAINER_FORMATS\n    delims         = format.delimiter_pair(DEFAULT_ARRAY_DELIMITERS)\n\n    # Make indentation active, if array is in alternative format, or if nested in indenting\n    indentation = indentation.indenting(format.alt? || indentation.is_indenting?)\n\n    case format.format\n    when :a, :s, :p\n      buf = ''.dup\n      if indentation.breaks?\n        buf << \"\\n\"\n        buf << indentation.padding","sourceCodeStart":920,"sourceCodeEnd":956,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L920-L956","documentation":"StringConverter raises this FormatError when formatting a Regexp value with a conversion letter other than 's' (bare pattern source) or 'p' (pattern with Puppet // delimiters, via PRegexpType.regexp_to_s_with_delimiters). The else at string_converter.rb:938 raises FormatError('Regexp', f.format, 'sp'). Regexp is one of the most restrictive members of the format family — only two letters are legal.","triggerScenarios":"`String(/[a-z]+/, '%d')`, `String($pattern, '%p')` is fine but `'%q'`, `'%v'`, `'%s'` with alt flags aside — any letter except s/p applied to a Regexp value, e.g. building rule descriptions from pattern variables.","commonSituations":"Generating documentation or rule strings from regexp variables with a generic formatter; passing patterns through templating code that applies numeric formats to every value.","solutions":["Use '%p' to keep the // delimiters or '%s' for the bare pattern source","Convert first if you need other treatment: String($pattern.source ... ) or use the Regexp in a match expression","Whitelist dynamic format letters against %w[s p]"],"exampleFix":"# before\n$str = String($pattern, '%d')\n# after\n$str = String($pattern, '%p')","handlingStrategy":"validation","validationCode":"fmt = '%d'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Regexp\" unless %w[s p].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only %s and %p are valid for Regexp values","Use %p when delimiters matter for re-parsing, %s for the raw source","Keep patterns out of generic formatting pipelines"],"tags":["puppet","pops","string-conversion","format-error","regexp"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}