{"record":{"id":"921aa7e8137d2ae4","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-921aa7","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Boolean type - expected one of the characters 'tTyYdxXobBeEfgGaAsp'","messagePattern":"Illegal format '#(.+?)' specified for value of Boolean type - expected one of the characters 'tTyYdxXobBeEfgGaAsp'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":709,"sourceCode":"      # Boolean in numeric form, formated by integer rule\n      numeric_bool = val ? 1 : 0\n      string_formats = { Puppet::Pops::Types::PIntegerType::DEFAULT => f }\n      _convert(TypeCalculator.infer_set(numeric_bool), numeric_bool, string_formats, indentation)\n\n    when :e, :E, :f, :g, :G, :a, :A\n      # Boolean in numeric form, formated by float rule\n      numeric_bool = val ? 1.0 : 0.0\n      string_formats = { Puppet::Pops::Types::PFloatType::DEFAULT => f }\n      _convert(TypeCalculator.infer_set(numeric_bool), numeric_bool, string_formats, indentation)\n\n    when :s\n      apply_string_flags(f, val.to_s)\n\n    when :p\n      apply_string_flags(f, val.inspect)\n\n    else\n      raise FormatError.new('Boolean', f.format, 'tTyYdxXobBeEfgGaAsp')\n    end\n  end\n\n  # Performs post-processing of literals to apply width and precision flags\n  def apply_string_flags(f, literal_str)\n    if f.left || f.width || f.prec\n      fmt = '%'.dup\n      fmt << '-' if f.left\n      fmt << f.width.to_s if f.width\n      fmt << '.' << f.prec.to_s if f.prec\n      fmt << 's'\n      Kernel.format(fmt, literal_str)\n    else\n      literal_str\n    end\n  end\n  private :apply_string_flags\n","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L691-L727","documentation":"StringConverter raises this FormatError when formatting a Boolean with a format letter outside 'tTyYdxXobBeEfgGaAsp'. Booleans support true/false rendering (t), yes/no-ish forms (T), numeric conversion (dxXobBeEfgGaA — the value becomes 1.0/0.0 and is reformatted), and s/p for string/inspect forms. The else at string_converter.rb:709 fires for any other letter, e.g. '%q' or '%v'.","triggerScenarios":"`String(true, '%q')`, `String($flag, '%v')`, `String(false, '%c')` — any conversion letter not in the allowed set applied to a Puppet Boolean. Often hit when a generic formatter applies one format string to a mixed hash of booleans, strings and numbers.","commonSituations":"Templating/report code that walks option hashes and applies a per-structure format; migrating Ruby `sprintf('%d', bool)` habits — %d actually works here, but %q (Ruby inspect idiom) does not.","solutions":["Use '%t'/'%T' for true/false or yes/no style output, '%s' for plain string form","Branch on datatype before formatting mixed collections (case $v { Boolean: ..., default: ... })","Whitelist the format letter against %w[t T y Y d x X o b B e E f g G a A s p]"],"exampleFix":"# before\n$str = String($enabled, '%q')\n# after\n$str = String($enabled, '%t')","handlingStrategy":"validation","validationCode":"fmt = '%q'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Boolean\" unless %w[t T y Y d x X o b B e E f g G a A s p].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use %t/%T for word forms of booleans","Format mixed data with a case-on-type dispatcher instead of one fixed format","Remember %q (Ruby inspect habit) is not a Boolean format"],"tags":["puppet","pops","string-conversion","format-error","boolean"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}