{"record":{"id":"e48b1d92a3bc0933","repo":"puppetlabs/puppet","slug":"duplicate-device-found-at-file-error-location","errorCode":null,"errorMessage":"Duplicate device found at %{file_error_location}, already found at %{device_error_location}","messagePattern":"Duplicate device found at %(.+?), already found at %(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/network_device/config.rb","lineNumber":59,"sourceCode":"      devices = {}\n      device = nil\n      File.open(@file) do |f|\n        file_line_count = 1\n        f.each do |line|\n          case line\n          when /^\\s*#/ # skip comments\n            file_line_count += 1\n            next\n          when /^\\s*$/ # skip blank lines\n            file_line_count += 1\n            next\n          when /^\\[([\\w.-]+)\\]\\s*$/ # [device.fqdn]\n            name = ::Regexp.last_match(1)\n            name.chomp!\n            if devices.include?(name)\n              file_error_location = Puppet::Util::Errors.error_location(nil, file_line_count)\n              device_error_location = Puppet::Util::Errors.error_location(nil, device.line)\n              raise Puppet::Error, _(\"Duplicate device found at %{file_error_location}, already found at %{device_error_location}\") %\n                                   { file_error_location: file_error_location, device_error_location: device_error_location }\n            end\n            device = OpenStruct.new\n            device.name = name\n            device.line = file_line_count\n            device.options = { :debug => false }\n            Puppet.debug \"found device: #{device.name} at #{device.line}\"\n            devices[name] = device\n          when /^\\s*(type|url|debug)(\\s+(.+)\\s*)*$/\n            parse_directive(device, ::Regexp.last_match(1), ::Regexp.last_match(3), file_line_count)\n          else\n            error_location_str = Puppet::Util::Errors.error_location(nil, file_line_count)\n            raise Puppet::Error, _(\"Invalid entry at %{error_location}: %{file_text}\") %\n                                 { error_location: error_location_str, file_text: line }\n          end\n        end\n      end\n    rescue Errno::EACCES","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/network_device/config.rb#L41-L77","documentation":"Raised while parsing a network device configuration file: a [device.fqdn] section header names a device that has already been defined earlier in the same file. Duplicate device definitions are ambiguous — Puppet cannot decide which entry describes the device — so parsing aborts with both locations reported.","triggerScenarios":"Thrown at lib/puppet/util/network_device/config.rb:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove or rename the duplicate [device.fqdn] section in the device config file","Keep only one entry per device, using the later or correct location","Search the file for repeated section headers with the same device name"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","contentChangedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}