[PUP-8347] Find more places where we report the file or line information and convert them to use error_location() Created: 2018/01/11  Updated: 2018/02/05  Resolved: 2018/01/26

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: PUP 5.3.4

Type: Task Priority: Normal
Reporter: Eric Delaney Assignee: Eric Delaney
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Epic Link: Agent i18n/l10n testing
Sub-team: Coremunity
Team: Platform Core
Sprint: Platform Core KANBAN
Release Notes: Not Needed
QA Risk Assessment: No Action

 Description   

We need to grep the puppet code base and find more of the locations that we report the file and line location information for an error and use the Puppet::Util::Errors.error_location() method to create the string so we are consistent.

For example:

16:03 $ grep -nr 'at line' lib
lib/puppet/settings/config_file.rb:86:        raise(Puppet::Error, _("Illegal section '%{name}' in config file %{file} at line %{line}. The only valid puppet.conf sections are: [%{allowed_sections}]. Please use the directory environments feature to specify environments. (See https://docs.puppet.com/puppet/latest/reference/environments.html)") % { name: section.name, file: file, line: section.line_number, allowed_sections: allowed_section_names.join(", ") })
lib/puppet/pops/issues.rb:779:    fl ? _("%{msg}. First defined at line %{line}") % { msg: msg, line: fl } : msg
lib/puppet/pops/issues.rb:789:    fl ? _("%{msg}. First defined at line %{line}") % { msg: msg, line: fl } : msg
lib/puppet/util/network_device/config.rb:55:            raise Puppet::Error, _("Duplicate device found at line %{count}, already found at %{line}") % { count: count, line: device.line } if devices.include?(name)
lib/puppet/util/network_device/config.rb:94:      raise Puppet::Error, _("Invalid argument '%{var}' at line %{count}") % { var: var, count: count }
lib/puppet/network/auth_config_parser.rb:32:          raise Puppet::ConfigurationError, _("Missing or invalid 'path' before right directive at line %{count} of %{file}") % { count: count, file: @file }
lib/puppet/network/auth_config_parser.rb:69:        _("Invalid argument '%{var}' at line %{count}") % { var: var, count: count }
lib/puppet/network/auth_config_parser.rb:80:        raise Puppet::ConfigurationError, _("%{detail} at line %{count} of %{file}") % { detail: detail, count: count, file: @file }, detail.backtrace
$

More cases to consider:

16:05 $ egrep -nr 'at .*file.*:.*line' lib
lib/puppet/settings/config_file.rb:86:        raise(Puppet::Error, _("Illegal section '%{name}' in config file %{file} at line %{line}. The only valid puppet.conf sections are: [%{allowed_sections}]. Please use the directory environments feature to specify environments. (See https://docs.puppet.com/puppet/latest/reference/environments.html)") % { name: section.name, file: file, line: section.line_number, allowed_sections: allowed_section_names.join(", ") })
lib/puppet/file_serving/configuration/parser.rb:43:          raise ArgumentError.new(_("Invalid line '%{line}' at %{file}, line %{line_num}") % { line: line.chomp, file: @file.filename, line_num: @count })
lib/puppet/file_serving/configuration/parser.rb:89:    raise ArgumentError.new(_("%{mount} is already mounted at %{name} in %{file}, line %{line_num}") % { mount: @mounts[name], name: name, file: @file, line_num: @count }) if @mounts.include?(name)
lib/puppet/util/logging.rb:184:          _("\n   (at %{file}:%{line})") % { file: file, line: line }
lib/puppet/parser/scope.rb:643:                   " at #{position[:file]}:#{position[:line]}"



 Comments   
Comment by Eric Delaney [ 2018/01/17 ]

Part 1 (scope.rb) merged to 5.3.x at https://github.com/puppetlabs/puppet/commit/f4b9743b681be76fb2f2c808d409a8f58c9fefc3 (last one merged)
Part 2 (file_server) merged to 5.3.x at https://github.com/puppetlabs/puppet/commit/3c09d97c69b965ea988bb45a89f8b2f2745e59bf
Part 3 (settings/config_file) merged to 5.3.x at https://github.com/puppetlabs/puppet/commit/378eb76d603685e870fd167bde3feddd4b50eecc
Part 4 (auth_config) merged to 5.3.x at https://github.com/puppetlabs/puppet/commit/0a70205a2c9e5c3854a2d961f4547f4f71f9ad08
Part 5 (network_device) merged to 5.3.x at https://github.com/puppetlabs/puppet/commit/61a9a1c2c14ab1f0917276a8f3d1e0674859d491
Part 6 (pops/issues) merged to 5.3.x at https://github.com/puppetlabs/puppet/commit/41c3b23553f353dc26f82c1e8fe8c5daea779444

Generated at Fri Jan 24 23:21:07 PST 2020 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.