{"record":{"id":"691505887744f93a","repo":"puppetlabs/puppet","slug":"invalid-mount-name-format-name","errorCode":null,"errorMessage":"Invalid mount name format '%{name}'","messagePattern":"Invalid mount name format '%(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/file_serving/mount.rb","lineNumber":22,"sourceCode":"require_relative '../../puppet/file_serving'\nrequire_relative '../../puppet/file_serving/metadata'\nrequire_relative '../../puppet/file_serving/content'\n\n# Broker access to the filesystem, converting local URIs into metadata\n# or content objects.\nclass Puppet::FileServing::Mount\n  include Puppet::Util::Logging\n\n  attr_reader :name\n\n  def find(path, options)\n    raise NotImplementedError\n  end\n\n  # Create our object.  It must have a name.\n  def initialize(name)\n    unless name =~ /^[-\\w]+$/\n      raise ArgumentError, _(\"Invalid mount name format '%{name}'\") % { name: name }\n    end\n\n    @name = name\n\n    super()\n  end\n\n  def search(path, options)\n    raise NotImplementedError\n  end\n\n  def to_s\n    \"mount[#{@name}]\"\n  end\n\n  # A noop.\n  def validate\n  end","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/file_serving/mount.rb#L4-L40","documentation":"Puppet::FileServing::Mount#initialize validates the mount name against /^[-\\w]+$/ (letters, digits, underscore, hyphen only). The name becomes the first path component of puppet:///<mount>/... URIs, so slashes, dots, spaces, or other characters break URI routing and are rejected immediately.","triggerScenarios":"A fileserver.conf section header like `[my.mount]`, `[my modules]`, `[a/b]`, or an empty-ish header; the same validation applies wherever a Mount subclass is instantiated programmatically.","commonSituations":"Naming mounts after dotted hostnames or domain paths; pasting section headers with trailing whitespace or smart quotes; scripts that generate fileserver.conf from arbitrary directory names.","solutions":["Rename the mount to use only [A-Za-z0-9_-], e.g. `[my_data]` or `[my-data]`","Update any `puppet:///<mount>/...` source URIs that referenced the old name","If generating configs programmatically, sanitize names with `name.gsub(/[^-\\w]/, '_')` before writing the header"],"exampleFix":"# before (fileserver.conf)\n[app.data]\n  path /srv/app/data\n\n# after\n[app_data]\n  path /srv/app/data","handlingStrategy":"validation","validationCode":"MOUNT_NAME = /\\A[-\\w]+\\z/\n\ndef valid_mount_name?(name)\n  name.is_a?(String) && name.match?(MOUNT_NAME)\nend","typeGuard":"def mount_header(line)\n  m = line.match(/\\A\\s*\\[([-\\w]+)\\]\\s*\\z/)\n  m && m[1]\nend","tryCatchPattern":"begin\n  mount = Puppet::FileServing::Mount::File.new(name)\nrescue ArgumentError => e\n  raise unless e.message.start_with?('Invalid mount name format')\n  name = name.gsub(/[^-\\w]/, '_')\n  retry\nend","preventionTips":["Restrict mount names to [A-Za-z0-9_-] by convention","Sanitize generated names before writing section headers","Remember the mount name is the first URI segment of puppet:///<mount>/..."],"tags":["puppet","fileserver","mount","name-validation","argumenterror"],"backgroundTag":"invalid-identifier","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}