puppetlabs/puppet · error · ArgumentError

The format must be a one letter format specifier, got '#

Error message

The format must be a one letter format specifier, got '#{@format}'

What it means

A generic guard after regex matching: the captured format specifier is not a single-letter String, so the format character cannot be used as a Symbol key by later conversion logic.

Solutions

  1. Use exactly one alphabetic format specifier character (e.g. 'd', 'f', 's', 'x')
  2. Remove any trailing characters after the format letter
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/pops/types/string_converter.rb:111 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/bf40ee1ca83c47ce. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/pops/types/string_converter.rb:111

    DELIMITER_MAP = {
      '[' => ['[', ']'],
      '{' => ['{', '}'],
      '(' => ['(', ')'],
      '<' => ['<', '>'],
      '|' => ['|', '|'],
      :space => ['', '']
    }.freeze

    def initialize(fmt)
      @orig_fmt = fmt
      match = FMT_PATTERN.match(fmt)
      unless match
        raise ArgumentError, "The format '#{fmt}' is not a valid format on the form '%<flags><width>.<prec><format>'"
      end

      @format = match[4]
      unless @format.is_a?(String) && @format.length == 1
        raise ArgumentError, "The format must be a one letter format specifier, got '#{@format}'"
      end

      @format = @format.to_sym
      flags  = match[1].split('') || []
      unless flags.uniq.size == flags.size
        raise ArgumentError, "The same flag can only be used once, got '#{fmt}'"
      end

      @left  = flags.include?('-')
      @alt   = flags.include?('#')
      @plus  = if flags.include?(' ')
                 :space
               else
                 flags.include?('+') ? :plus : :ignore
               end
      @zero_pad = flags.include?('0')

      @delimiters = nil

View on GitHub (pinned to e227c27540)