{"record":{"id":"b98b4d33989106b5","repo":"puppetlabs/puppet","slug":"cannot-manage-files-of-type-file-type","errorCode":null,"errorMessage":"Cannot manage files of type %{file_type}","messagePattern":"Cannot manage files of type %(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/file_serving/metadata.rb","lineNumber":129,"sourceCode":"\n    case stat.ftype\n    when \"file\"\n      @checksum = \"{#{@checksum_type}}\" + send(\"#{@checksum_type}_file\", real_path).to_s\n    when \"directory\" # Always just timestamp the directory.\n      @checksum_type = \"ctime\"\n      @checksum = \"{#{@checksum_type}}\" + send(\"#{@checksum_type}_file\", path).to_s\n    when \"link\"\n      @destination = Puppet::FileSystem.readlink(real_path)\n      @checksum = begin\n        \"{#{@checksum_type}}\" + send(\"#{@checksum_type}_file\", real_path).to_s\n      rescue\n        nil\n      end\n    when \"fifo\", \"socket\"\n      @checksum_type = \"none\"\n      @checksum = \"{#{@checksum_type}}\" + send(\"#{@checksum_type}_file\", real_path).to_s\n    else\n      raise ArgumentError, _(\"Cannot manage files of type %{file_type}\") % { file_type: stat.ftype }\n    end\n  end\n\n  def initialize(path, data = {})\n    @owner       = data.delete('owner')\n    @group       = data.delete('group')\n    @mode        = data.delete('mode')\n    checksum = data.delete('checksum')\n    if checksum\n      @checksum_type = checksum['type']\n      @checksum      = checksum['value']\n    end\n    @checksum_type ||= Puppet[:digest_algorithm]\n    @ftype       = data.delete('type')\n    @destination = data.delete('destination')\n    @source      = data.delete('source')\n    @content_uri = data.delete('content_uri')\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/file_serving/metadata.rb#L111-L147","documentation":"Puppet::FileServing::Metadata builds checksums per stat.ftype and handles file, directory, link, fifo, and socket. Any other ftype (Ruby returns 'blockSpecial' or 'characterSpecial' for device nodes) falls into the else branch and raises ArgumentError, because Puppet cannot compute a meaningful checksum/destination for such files.","triggerScenarios":"Requesting metadata (or a file resource with `source =>` pointing into a directory containing device nodes such as /dev/null-style files); serving a mount whose path includes /dev or another pseudo-filesystem with special files; `puppet file bucket`/file_serving indirection hitting a device file.","commonSituations":"Recursive file resources pointed at directories that contain Unix device nodes or exotic FIFO/socket-adjacent entries; accidentally using an absolute source path that reaches into /dev; chroot/container images with device files in unexpected places.","solutions":["Exclude device files from the recursion with the `ignore` parameter or by narrowing the served path","Do not serve or manage /dev or other pseudo-filesystems with file resources","If a specific special file must exist, declare it explicitly (ensure => present with mode/owner) instead of copying it via source"],"exampleFix":"# before\nfile { '/opt/app/dev':\n  ensure  => directory,\n  source  => 'puppet:///modules/app/dev', # contains device nodes\n  recurse => true,\n}\n\n# after\nfile { '/opt/app/dev':\n  ensure  => directory,\n  source  => 'puppet:///modules/app/dev',\n  recurse => true,\n  ignore  => ['tty*', 'sd*'],\n}","handlingStrategy":"validation","validationCode":"MANAGEABLE_FTYPES = %w[file directory link fifo socket].freeze\n\ndef metadata_safe?(path)\n  MANAGEABLE_FTYPES.include?(File.stat(path).ftype)\nend","typeGuard":"def puppet_manageable_file?(path)\n  return false unless Puppet::FileSystem.exist?(path)\n  MANAGEABLE_FTYPES.include?(Puppet::FileSystem.stat(path).ftype)\nend","tryCatchPattern":"begin\n  Puppet::FileServing::Metadata.new(path)\nrescue ArgumentError => e\n  raise unless e.message.start_with?('Cannot manage files of type')\n  skip path # device/special file: log and continue the walk\nend","preventionTips":["Never point recursive file resources at /dev or pseudo-filesystems","Add ignore patterns for device-like entries in risky trees","In custom walkers, filter on File.stat.ftype before requesting metadata"],"tags":["puppet","metadata","unsupported-file-type","argumenterror","stat"],"backgroundTag":"unsupported-file-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}