{"record":{"id":"2edda4ed7fe65dce","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-2edda4","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Default type - expected one of the characters 'dDsp'","messagePattern":"Illegal format '#(.+?)' specified for value of Default type - expected one of the characters 'dDsp'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":638,"sourceCode":"\n  # Basically string_PAnyType converts the value to a String and then formats it according\n  # to the resulting type\n  #\n  # @api private\n  def string_PAnyType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    Kernel.format(f.orig_fmt, val)\n  end\n\n  def string_PDefaultType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    apply_string_flags(f, case f.format\n                          when :d, :s, :p\n                            f.alt? ? '\"default\"' : 'default'\n                          when :D\n                            f.alt? ? '\"Default\"' : 'Default'\n                          else\n                            raise FormatError.new('Default', f.format, 'dDsp')\n                          end)\n  end\n\n  # @api private\n  def string_PUndefType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    apply_string_flags(f, case f.format\n                          when :n\n                            f.alt? ? 'null' : 'nil'\n                          when :u\n                            f.alt? ? 'undefined' : 'undef'\n                          when :d, :x, :X, :o, :b, :B, :e, :E, :f, :g, :G, :a, :A\n                            'NaN'\n                          when :v\n                            'n/a'\n                          when :V\n                            'N/A'\n                          when :s","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L620-L656","documentation":"StringConverter raises this FormatError when formatting the special `default` value (PDefaultType) with a format character outside 'dDsp': 'd'/'s' render 'default', 'D' renders 'Default', 'p' quotes per Puppet notation, with alt-flag (#) variants adding quotes. Any other letter hits the else at string_converter.rb:638 and raises FormatError('Default', f.format, 'dDsp').","triggerScenarios":"`String(default, '%v')`, `String(default, '%t')` or any conversion letter not in d/D/s/p applied to the Puppet `default` value; a format map applied uniformly to a data structure that happens to contain `default` entries.","commonSituations":"Iterating heterogeneous option hashes where one entry is `default` and applying a single format string to all values; porting sprintf-style templates that use %v (which is legal for Undef but not for Default).","solutions":["Use '%d', '%D', '%s' or '%p' when stringifying `default`","Branch before formatting: `if $v == default { ... } else { String($v, $fmt) }`","Check the value against the allowed letters when the format is user/data supplied"],"exampleFix":"# before\n$str = String(default, '%v')\n# after\n$str = String(default, '%s')","handlingStrategy":"validation","validationCode":"fmt = '%v'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for the default value\" unless %w[d D s p].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Handle `default` explicitly (case/if) before applying generic formatting to option values","Remember %v is legal for Undef but illegal for Default","Whitelist format letters per type when formats are data-driven"],"tags":["puppet","pops","string-conversion","format-error","default-type"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}