puppetlabs/puppet · error · Puppet::Error

The umask specification is invalid: %{value}

Error message

The umask specification is invalid: %{value}

What it means

The exec type's umask parameter (only honored for providers with the umask feature) munges its value by matching ^0?[0-7]{1,4}$ — an optional leading zero plus one to four octal digits. Anything else (digits 8/9, '0o022' notation, five-plus digits, arbitrary strings) raises Puppet::Error 'The umask specification is invalid' with the inspected value, failing validation before the run.

Source

Thrown at lib/puppet/type/exec.rb:322

      validate do |values|
        values = [values] unless values.is_a? Array
        values.each do |value|
          unless value =~ /\w+=/
            raise ArgumentError, _("Invalid environment setting '%{value}'") % { value: value }
          end
        end
      end
    end

    newparam(:umask, :required_feature => :umask) do
      desc "Sets the umask to be used while executing this command"

      munge do |value|
        if value =~ /^0?[0-7]{1,4}$/
          return value.to_i(8)
        else
          raise Puppet::Error, _("The umask specification is invalid: %{value}") % { value: value.inspect }
        end
      end
    end

    newparam(:timeout) do
      desc "The maximum time the command should take.  If the command takes
        longer than the timeout, the command is considered to have failed
        and will be stopped. The timeout is specified in seconds. The default
        timeout is 300 seconds and you can set it to 0 to disable the timeout."

      munge do |value|
        value = value.shift if value.is_a?(Array)
        begin
          value = Float(value)
        rescue ArgumentError => e
          raise ArgumentError, _("The timeout must be a number."), e.backtrace
        end
        [value, 0.0].max

View on GitHub (pinned to e227c27540)

Solutions

  1. Use one to four octal digits with optional leading zero: umask => '0022'
  2. Quote YAML values to avoid YAML 1.1 octal coercion surprises: umask: "0022"
  3. Strip shell syntax from data: 'umask 022' -> '022'
  4. If the value is dynamic, validate first in Ruby: value.match?(/\A0?[0-7]{1,4}\z/)

Example fix

# before
exec { 'build': command => '/bin/build', umask => '0o022' } # => Puppet::Error

# after
exec { 'build': command => '/bin/build', umask => '0022' }
Defensive patterns

Strategy: validation

Validate before calling

value = value.shift if value.is_a?(Array)
raise Puppet::Error, "bad umask #{value}" unless value.to_s.match?(/\A0?[0-7]{1,4}\z/)

Prevention

When it happens

Trigger: exec { 'x': umask => '0778' } (invalid octal digit); umask => '0o022' (Ruby-style literal); umask => '002277' (too long); values arriving from hiera as strings like 'umask 022'. Note valid examples: '022', '0022', '77', 22 (integer munged via regex).

Common situations: Copy-pasting shell syntax ('umask 022') into the parameter; YAML config quoting octals as '0o...' (YAML 1.2 style) or letting YAML coerce 022 to octal 18 then re-stringify oddly; team conventions disagreeing on 3 vs 4 digit masks.

Related errors


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