{"record":{"id":"36aa72ef79e096f4","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-36aa72","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Binary type - expected one of the characters 'bButTsp'","messagePattern":"Illegal format '#(.+?)' specified for value of Binary type - expected one of the characters 'bButTsp'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":814,"sourceCode":"    when :b\n      Kernel.format(f.orig_fmt.gsub('b', substitute), val.relaxed_to_s)\n\n    when :B\n      Kernel.format(f.orig_fmt.gsub('B', substitute), val.to_s)\n\n    when :u\n      Kernel.format(f.orig_fmt.gsub('u', substitute), val.urlsafe_to_s)\n\n    when :t\n      # Output as the type without any data\n      Kernel.format(f.orig_fmt.gsub('t', substitute), 'Binary')\n\n    when :T\n      # Output as the type without any data in all caps\n      Kernel.format(f.orig_fmt.gsub('T', substitute), 'BINARY')\n\n    else\n      raise FormatError.new('Binary', f.format, 'bButTsp')\n    end\n  end\n\n  # @api private\n  def string_PStringType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    case f.format\n    when :s\n      Kernel.format(f.orig_fmt, val)\n\n    when :p\n      apply_string_flags(f, puppet_quote(val, f.alt?))\n\n    when :c\n      c_val = val.capitalize\n      f.alt? ? apply_string_flags(f, puppet_quote(c_val)) : Kernel.format(f.orig_fmt.tr('c', 's'), c_val)\n\n    when :C","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L796-L832","documentation":"StringConverter raises this FormatError when formatting a Binary value (Puppet::Pops::Types::PBinaryType — base64-wrapped byte data) with a conversion letter outside 'bButTsp': 'b' (base64), 'u' (URL-safe base64), 't'/'T' (the literal word 'Binary'/'BINARY', type-only output), 's'/'p' (string/quoted forms). The else at string_converter.rb:814 raises FormatError('Binary', f.format, 'bButTsp').","triggerScenarios":"`String(Binary('aGVsbG8='), '%d')`, `String($blob, '%x')` — any letter not in bButTsp applied to a Binary value; typically when generic numeric formats are applied to secrets/certificates/blobs stored as Binary via Binary()/Base64 decode.","commonSituations":"Handling PEM certs, DER keys or file contents loaded as Binary in tasks/plans; piping Binary into a shared formatting helper that assumes scalars; trying to hex-dump binary data with %x (not supported — use a dedicated function).","solutions":["Use '%b' for base64 output or '%u' for URL-safe base64","Use '%s' only when the buffer is valid UTF-8 text (raw binary will produce broken strings)","Whitelist dynamic format letters against %w[b B u t T s p]"],"exampleFix":"# before\n$str = String($blob, '%d')\n# after\n$str = String($blob, '%b')","handlingStrategy":"validation","validationCode":"fmt = '%d'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Binary\" unless %w[b B u t T s p].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use %b/%u for base64 forms of Binary values","Never apply scalar formats to Binary blobs; convert deliberately (Base64 decode) first","Type-guard data pipelines so Binary never reaches generic formatters"],"tags":["puppet","pops","string-conversion","format-error","binary"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}