{"record":{"id":"cc5d2f1d3dfc147e","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-cc5d2f","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Array type - expected one of the characters 'asp'","messagePattern":"Illegal format '#(.+?)' specified for value of Array type - expected one of the characters 'asp'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":1015,"sourceCode":"        else\n          buf << sep\n          # if break on each (and breaking will not occur because next is an array or hash)\n          # or, if indenting, and previous was an array or hash, then break and continue on next line\n          # indented.\n          if (sz_break && !is_a_or_h?(v)) || (format.alt? && i > 0 && is_a_or_h?(val[i - 1]) && !is_a_or_h?(v))\n            buf.rstrip! unless buf[-1] == \"\\n\"\n            buf << \"\\n\"\n            buf << children_indentation.padding\n          end\n        end\n        # remove trailing space added by separator if followed by break\n        buf.rstrip! if buf[-1] == ' ' && str_val[0] == \"\\n\"\n        buf << str_val\n      end\n      buf << delims[1]\n      buf\n    else\n      raise FormatError.new('Array', format.format, 'asp')\n    end\n  end\n\n  def is_a_or_h?(x)\n    x.is_a?(Array) || x.is_a?(Hash)\n  end\n\n  def is_container?(t)\n    case t\n    when PArrayType, PHashType, PStructType, PTupleType, PObjectType\n      true\n    else\n      false\n    end\n  end\n\n  # @api private\n  def string_PTupleType(val_type, val, format_map, indentation)","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L997-L1033","documentation":"StringConverter raises this FormatError when formatting an Array with a container format letter outside 'asp': 'a' (angle/normal array rendering with per-element formats), 's' (plain to_s style) and 'p' (Puppet-notation, quoted elements). Container formats also carry separator/delimiter options parsed from the format string, but the leading letter itself must be a/s/p; otherwise the else at string_converter.rb:1015 raises FormatError('Array', format.format, 'asp').","triggerScenarios":"`String([1,2,3], '%d')` — applying a scalar format as the container letter; in general any `String($array, '<letter>...')` where the letter is not a/s/p. Note per-element formats are specified inside the container format (e.g. '%(d, )' style); putting the element format first is the classic mistake.","commonSituations":"Rendering lists into templates/logs and reusing an element format as the top-level letter; upgrading code from join() to String() with formats and misplacing the letters.","solutions":["Use '%a' for array formatting and put element formats in the container options, e.g. String($arr, '%a') or with per-element format via the container syntax","Use '%s' for simple rendering or '%p' for Puppet-notation output","Whitelist the container letter against %w[a s p]"],"exampleFix":"# before\n$str = String([1, 2, 3], '%d')\n# after\n$str = String([1, 2, 3], '%a')","handlingStrategy":"validation","validationCode":"fmt = '%d'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Array (container letter must be a/s/p)\" unless %w[a s p].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use %a as the array container letter and express element formats in the container options","Prefer join() when you only need a flat string","Distinguish container formats from element formats in shared format configuration"],"tags":["puppet","pops","string-conversion","format-error","array"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}