{"record":{"id":"e5d6c76c738b4d01","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Object type - expected one of the characters 'spq'","messagePattern":"Illegal format '#(.+?)' specified for value of Object 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":585,"sourceCode":"    result.container_string_formats = validate_input(fmt['string_formats'])\n    result\n  end\n  private :validate_container_input\n\n  def string_PObjectType(val_type, val, format_map, indentation)\n    f = get_format(val_type, format_map)\n    case f.format\n    when :p\n      fmt = TypeFormatter.singleton\n      indentation = indentation.indenting(f.alt? || indentation.is_indenting?)\n      fmt = fmt.indented(indentation.level, 2) if indentation.is_indenting?\n      fmt.string(val)\n    when :s\n      val.to_s\n    when :q\n      val.inspect\n    else\n      raise FormatError.new('Object', f.format, 'spq')\n    end\n  end\n\n  def string_PObjectTypeExtension(val_type, val, format_map, indentation)\n    string_PObjectType(val_type.base_type, val, format_map, indentation)\n  end\n\n  def string_PRuntimeType(val_type, val, format_map, indent)\n    # Before giving up on this, and use a string representation of the unknown\n    # object, a check is made to see if the object can present itself as\n    # a hash or an array. If it can, then that representation is used instead.\n    case val\n    when Hash\n      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","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L567-L603","documentation":"StringConverter (Puppet::Pops::Types::StringConverter) raises FormatError — an ArgumentError subclass — when `String(value, format)` is asked to render an Object type value with a format character outside the allowed set. For PObjectType values only 's' (to_s), 'p' (TypeFormatter, Puppet-notation) and 'q' (inspect) are legal; any other char falls into the else branch at string_converter.rb:585 and raises with the type name 'Object' and the valid set 'spq'. This is the object-type member of Puppet's per-type printf-style format validation family.","triggerScenarios":"In Puppet DSL: `String($my_object, '%d')` or any format string whose conversion letter is not s/p/q applied to a Puppet Object value. In Ruby: StringConverter.convert inferred a PObjectType for the value and the format map (e.g. from puppetlabs-stdlib or custom function options) contains an invalid char.","commonSituations":"Reusing a printf format meant for scalars against an object attribute; copy-pasting `'%v'` or `'%d'` formats from Integer/String examples; passing user-supplied format strings from Hiera into a function that formats an Object.","solutions":["Use '%p' (Puppet notation via TypeFormatter) or '%s' (plain to_s) for Object values","Format a specific attribute instead of the whole object: String($obj.field, '%d')","If the format arrives from data, validate its conversion letter against %w[s p q] before use"],"exampleFix":"# before\n$str = String($my_object, '%d')\n# after\n$str = String($my_object, '%p')","handlingStrategy":"validation","validationCode":"# Validate the conversion letter before formatting an Object value\nfmt = '%d'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Object\" unless %w[s p q].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use %p for Puppet notation or %s for plain rendering of Objects","Keep one format per Puppet type, not one shared format for all values","Reject user/data-supplied format strings that are not on a per-type whitelist"],"tags":["puppet","pops","string-conversion","format-error","object-type"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}