{"record":{"id":"c092efcaa2e0b160","repo":"puppetlabs/puppet","slug":"invalid-file-option-parameter","errorCode":null,"errorMessage":"Invalid file option '%{parameter}'","messagePattern":"Invalid file option '%(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/settings/config_file.rb","lineNumber":133,"sourceCode":"      raise Puppet::Settings::ParseError.new(detail.message, file, setting.line_number, detail)\n    end\n  end\n\n  def empty_section\n    { :_meta => {} }\n  end\n\n  def extract_fileinfo(string)\n    result = {}\n    value = string.sub(/\\{\\s*([^}]+)\\s*\\}/) do\n      params = ::Regexp.last_match(1)\n      params.split(/\\s*,\\s*/).each do |str|\n        if str =~ /^\\s*(\\w+)\\s*=\\s*(\\w+)\\s*$/\n          param = ::Regexp.last_match(1).intern\n          value = ::Regexp.last_match(2)\n          result[param] = value\n          unless [:owner, :mode, :group].include?(param)\n            raise ArgumentError, _(\"Invalid file option '%{parameter}'\") % { parameter: param }\n          end\n\n          if param == :mode and value !~ /^\\d+$/\n            raise ArgumentError, _(\"File modes must be numbers\")\n          end\n        else\n          raise ArgumentError, _(\"Could not parse '%{string}'\") % { string: string }\n        end\n      end\n      ''\n    end\n    result[:value] = value.sub(/\\s*$/, '')\n    result\n  end\nend\n","sourceCodeStart":115,"sourceCodeEnd":149,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/settings/config_file.rb#L115-L149","documentation":"In puppet.conf-style files, a setting line may carry a {...} file-options block parsed by Puppet::Settings::ConfigFile#extract_fileinfo (e.g. `$privatekeydir { owner = puppet, mode = 750 }`). Only owner, mode, and group are permitted; a `name = value` pair inside the braces whose param is anything else raises ArgumentError 'Invalid file option'.","triggerScenarios":"Writing `vardir = /opt/puppet { owner = puppet, backup = true }` (backup not allowed); attempting ensure, create, path, or selrange inside the braces; copying docs that show unsupported per-setting file attributes.","commonSituations":"Users trying to manage more file attributes than Puppet supports per-setting; old 2.x-era documentation showing options modern Puppet rejects; hand-merged config files during upgrades.","solutions":["Keep only owner = <name>, mode = <digits>, and group = <name> inside {...} blocks.","Manage anything else (ensure, backup, selignored) with a normal file resource, not config-file braces.","Remove the invalid pair and re-parse the file with Puppet::Settings::ConfigFile to confirm."],"exampleFix":"# before (puppet.conf)\nvardir = /opt/puppet { owner = puppet, backup = true }\n\n# after\nvardir = /opt/puppet { owner = puppet, mode = 750 }","handlingStrategy":"validation","validationCode":"str.scan(/\\{\\s*([^}]+)\\s*\\}/).flatten.each do |block|\n  block.split(/\\s*,\\s*/).each do |pair|\n    m = pair.match(/^\\s*(\\w+)\\s*=\\s*(\\w+)\\s*$/)\n    param = m && m[1].to_sym\n    raise ArgumentError, \"invalid file option #{param} in #{pair}\" unless %i[owner mode group].include?(param)\n  end\nend","typeGuard":null,"tryCatchPattern":"begin\n  Puppet::Settings::ConfigFile.parse_file(file, text, [])\nrescue ArgumentError => e\n  raise unless e.message.include?('Invalid file option')\n  Puppet.err(\"only owner/mode/group allowed inside {...}: #{e.message}\")\n  raise\nend","preventionTips":["Restrict {...} blocks to owner, mode, group pairs only","Manage other file attributes with file resources, not config-file braces","Parse generated configs programmatically before shipping them"],"tags":["puppet","settings","config-file","file-options","argumenterror"],"backgroundTag":"invalid-config-file-syntax","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}