{"record":{"id":"ce49c037e649692f","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-ce49c0","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of String type - expected one of the characters 'cCudspt'","messagePattern":"Illegal format '#(.+?)' specified for value of String type - expected one of the characters 'cCudspt'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":849,"sourceCode":"\n    when :C\n      c_val = val.split('::').map(&:capitalize).join('::')\n      f.alt? ? apply_string_flags(f, puppet_quote(c_val)) : Kernel.format(f.orig_fmt.tr('C', 's'), c_val)\n\n    when :u\n      c_val = val.upcase\n      f.alt? ? apply_string_flags(f, puppet_quote(c_val)) : Kernel.format(f.orig_fmt.tr('u', 's'), c_val)\n\n    when :d\n      c_val = val.downcase\n      f.alt? ? apply_string_flags(f, puppet_quote(c_val)) : Kernel.format(f.orig_fmt.tr('d', 's'), c_val)\n\n    when :t # trim\n      c_val = val.strip\n      f.alt? ? apply_string_flags(f, puppet_quote(c_val)) : Kernel.format(f.orig_fmt.tr('t', 's'), c_val)\n\n    else\n      raise FormatError.new('String', f.format, 'cCudspt')\n    end\n  end\n\n  # Performs a '%p' formatting of the given _str_ such that the output conforms to Puppet syntax. An ascii string\n  # without control characters, dollar, single-qoute, or backslash, will be quoted using single quotes. All other\n  # strings will be quoted using double quotes.\n  #\n  # @param [String] str the string that should be formatted\n  # @param [Boolean] enforce_double_quotes if true the result will be double quoted (even if single quotes would be possible)\n  # @return [String] the formatted string\n  #\n  # @api public\n  def puppet_quote(str, enforce_double_quotes = false)\n    if enforce_double_quotes\n      return puppet_double_quote(str)\n    end\n\n    # Assume that the string can be single quoted","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L831-L867","documentation":"StringConverter raises this FormatError when formatting a String with a conversion letter outside 'cCudspt': 'c'/'C' (camel/upcase first letter... upcased copy), 'u' (uppercase), 'd' (downcase), 's' (as-is), 'p' (Puppet-quoted), 't' (strip whitespace). The else at string_converter.rb:849 raises FormatError('String', f.format, 'cCudspt'). Numeric letters that work for Integer/Float are illegal for String values.","triggerScenarios":"`String('hi', '%x')`, `String($name, '%d' )` used intending 'downcase' — %d for a String is illegal (d means downcase only in the sense of the letter list... actually 'd' IS allowed and downcases); the real trigger is letters like '%q', '%v', '%e' applied to String values. Any conversion letter not in cCudspt against a String.","commonSituations":"Copy-pasting numeric formats onto label/name data; applying '%v' (n/a) formatting from Undef examples to strings; format strings sourced from Hiera meant for a different field type.","solutions":["Use '%s' (plain), '%d' (downcase), '%u' (uppercase), '%t' (strip) or '%p' (quoted) for strings","Remember '%d' on a String means downcase — if you meant a number, convert first: String(Integer($s), '%d')","Whitelist dynamic format letters against %w[c C u d s p t]"],"exampleFix":"# before\n$str = String($label, '%q')\n# after\n$str = String($label, '%p')","handlingStrategy":"validation","validationCode":"fmt = '%x'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for String\" unless %w[c C u d s p t].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use %s/%d/%u/%t/%p for strings and remember %d means downcase on a String","Convert to Integer before applying numeric formats","Keep Hiera-sourced format strings per-field and type-checked"],"tags":["puppet","pops","string-conversion","format-error","string-type"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}