{"record":{"id":"313770e517d7a99f","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-313770","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Runtime type - expected one of the characters 'spq'","messagePattern":"Illegal format '#(.+?)' specified for value of Runtime type - expected one of the characters 'spq'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":617,"sourceCode":"      hash = val.to_hash\n      # Ensure that the returned value isn't derived from Hash\n      return string_PHashType(val_type, hash, format_map, indent) if hash.instance_of?(Hash)\n    when Array\n      array = val.to_a\n      # Ensure that the returned value isn't derived from Array\n      return string_PArrayType(val_type, array, format_map, indent) if array.instance_of?(Array)\n    end\n\n    f = get_format(val_type, format_map)\n    case f.format\n    when :s\n      val.to_s\n    when :p\n      puppet_quote(val.to_s)\n    when :q\n      val.inspect\n    else\n      raise FormatError.new('Runtime', f.format, 'spq')\n    end\n  end\n\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","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L599-L635","documentation":"Raised by StringConverter when formatting a Runtime type value (PRuntimeType — a Ruby object surfaced into the Puppet type system, e.g. Runtime['ruby', 'MyClass']) with a format character other than 's' (to_s), 'p' (puppet-quoted string) or 'q' (inspect). The else branch at string_converter.rb:617 raises FormatError('Runtime', f.format, 'spq'). Note the method first tries to coerce arrays/hashes into Puppet containers; the error only fires when the value stays an opaque runtime object.","triggerScenarios":"`String($ruby_obj, '%d')` where $ruby_obj has inferred type Runtime['ruby', ...]; custom Puppet functions in Ruby returning arbitrary objects that later flow into String(..., fmt) with a numeric/other format letter; format maps built for other types reused against runtime values.","commonSituations":"Mixing printf habits from C/Ruby into Puppet String() calls; formatting values returned by Ruby API extensions whose type cannot be mapped to a Puppet type; debugging output code that applies one hardcoded format to heterogeneous values.","solutions":["Use '%s', '%p' or '%q' for Runtime-typed values","Convert the object to a Puppet-native value first (to_s/to_hash/to_a) and format that","Validate the format letter against %w[s p q] when formats come from data"],"exampleFix":"# before\n$str = String($ruby_obj, '%d')\n# after\n$str = String($ruby_obj, '%s')","handlingStrategy":"validation","validationCode":"fmt = '%d'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Runtime values\" unless %w[s p q].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Convert runtime objects to Puppet-native data (hash/array/string) before formatting","Restrict formats applied to Runtime values to s/p/q","Avoid passing opaque Ruby objects across function boundaries when formatting follows"],"tags":["puppet","pops","string-conversion","format-error","runtime-type"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}