{"record":{"id":"b5697f5eec9fc95f","repo":"puppetlabs/puppet","slug":"illegal-format-actual-specified-for-value-of-b5697f","errorCode":null,"errorMessage":"Illegal format '#{actual}' specified for value of Float type - expected one of the characters 'dxXobBeEfgGaAsp'","messagePattern":"Illegal format '#(.+?)' specified for value of Float type - expected one of the characters 'dxXobBeEfgGaAsp'","errorType":"validation","errorClass":"Puppet::Pops::Types::StringConverter::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":768,"sourceCode":"    end\n  end\n\n  # @api private\n  def string_PFloatType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    case f.format\n    when :d, :x, :X, :o, :b, :B\n      Kernel.format(f.orig_fmt, val.to_i)\n\n    when :e, :E, :f, :g, :G, :a, :A, :p\n      Kernel.format(f.orig_fmt, val)\n\n    when :s\n      float_str = f.alt? ? \"\\\"#{Kernel.format('%p', val)}\\\"\" : Kernel.format('%p', val)\n      Kernel.format(f.orig_fmt, float_str)\n\n    else\n      raise FormatError.new('Float', f.format, 'dxXobBeEfgGaAsp')\n    end\n  end\n\n  # @api private\n  def string_PBinaryType(val_type, val, format_map, _)\n    f = get_format(val_type, format_map)\n    substitute = f.alt? ? 'p' : 's'\n    case f.format\n    when :s\n      val_to_convert = val.binary_buffer\n      if !f.alt?\n        # Assume it is valid UTF-8\n        val_to_convert = val_to_convert.dup.force_encoding('UTF-8')\n        # If it isn't\n        unless val_to_convert.valid_encoding?\n          # try to convert and fail with details about what is wrong\n          val_to_convert = val.binary_buffer.encode('UTF-8')\n        end","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L750-L786","documentation":"StringConverter raises this FormatError when formatting a Float with a conversion letter outside 'dxXobBeEfgGaAsp'. Floats accept integer-conversion letters (dxXobB — the value is truncated with val.to_i first), float letters (eEfgGaA), '%p' (Ruby inspect form) and '%s' (quoted inspect form with alt flag). Notably '%c' (character) — valid for Integer — is illegal here; the else at string_converter.rb:768 raises FormatError('Float', f.format, 'dxXobBeEfgGaAsp').","triggerScenarios":"`String(1.5, '%c')`, `String($ratio, '%v')`, `String(3.14, '%q')` — any letter not in dxXobBeEfgGaAsp applied to a Float value in DSL `String()` calls or Ruby StringConverter invocations.","commonSituations":"Reusing an Integer format list for floats and assuming %c carries over; applying per-collection formats to mixed numeric data; porting C printf specs that use %c for ordinals.","solutions":["Use '%f', '%e', '%g' (float forms), '%d' (truncates via to_i) or '%s' for floats","Convert to Integer first if you truly want character output: String(1.5.to_i, '%c')","Whitelist dynamic format letters against %w[d x X o b B e E f g G a A s p]"],"exampleFix":"# before\n$str = String($ratio, '%c')\n# after\n$str = String($ratio, '%f')","handlingStrategy":"validation","validationCode":"fmt = '%c'\nletter = fmt[/\\A%[#\\-+ 0\\d.]*([a-zA-Z])\\z/, 1]\nraise ArgumentError, \"#{fmt} invalid for Float\" unless %w[d x X o b B e E f g G a A s p].include?(letter)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use %f/%e/%g for floats; convert with .to_i first if integer semantics are wanted","Do not reuse Integer format lists verbatim for Floats (%c is Integer-only)","Whitelist dynamic format letters per numeric type"],"tags":["puppet","pops","string-conversion","format-error","float"],"backgroundTag":"invalid-format-specifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}