puppetlabs/puppet · error · ArgumentError
The format '# ' is not a valid format on the form '% .
Error message
The format '#{fmt}' is not a valid format on the form '%<flags><width>.<prec><format>' What it means
The Format constructor could not match the given format string against FMT_PATTERN ('%<flags><width>.<prec><format>'), meaning it is malformed rather than merely unsupported.
Solutions
- Rewrite the format as a percent-prefixed specifier, e.g. '%d', '%-10.3f', '%#x'
- Use only the recognized flag characters, a width, and a precision
- Check for a missing leading '%' or stray characters in the format string
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/puppet/pops/types/string_converter.rb:106 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/c9245d431f053372.
Report an issue: GitHub.
Appendix: source
Thrown at lib/puppet/pops/types/string_converter.rb:106
attr_reader :orig_fmt
FMT_PATTERN_STR = '^%([\s\[+#0{<(|-]*)([1-9][0-9]*)?(?:\.([0-9]+))?([a-zA-Z])$'
FMT_PATTERN = Regexp.compile(FMT_PATTERN_STR)
DELIMITERS = ['[', '{', '(', '<', '|']
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
elseView on GitHub (pinned to e227c27540)