Title: Message Title
Charlie Sharpsteen updated an issue
Puppet / PUP-8140
NoMethodErrors involving Puppet::Face instances do not have a useful text representation
Change By:
Charlie Sharpsteen
Acceptance Criteria:
The Puppet::Face class does not define a useful text representation for use in some error messages --- I.E. {{NoMethodError}}. This makes errors involving missing methods on Puppet Faces especially difficult to track down. Puppet Faces allow multiple versions, so these errors are easy to create by third-party modules defining a new Face version that other Puppet components don't expect.h2. Reproduction Case. - Install the latest puppet-agent 4.10.x on CentOS 7:{code:bash}rpm -Uvh http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpmyum install -y puppet-agent{code} - Create a module containing a Puppet Face that can fail due to multiple versions:{code:bash}mkdir -p /etc/puppetlabs/code/environments/production/modules/test_face/lib/puppet/applicationcat < /etc/puppetlabs/code/environments/production/modules/test_face/lib/puppet/application/foo.rbrequire 'puppet/application/face_base'class Puppet::Application::Foo < Puppet::Application::FaceBaseendEOFmkdir -p /etc/puppetlabs/code/environments/production/modules/test_face/lib/puppet/facecat < /etc/puppetlabs/code/environments/production/modules/test_face/lib/puppet/face/foo.rbPuppet::Face.define(:foo, '0.0.1') do action :bar dowhen_invoked do |*args| puts "Bar action called!"end end action :baz dowhen_invoked do |*args| puts "Baz action called!" Puppet::Face[:foo, :current].barend endendPuppet::Face.define(:foo, '0.0.2') do action :bim dowhen_invoked do |*args| puts "Bim action called!"end endendEOF{code} - Run the face to generate a failure: {{/opt/puppetlabs/puppet/bin/puppet foo baz}}h3. OutcomeThe error message indicates no {{baz}} method is avaiailble, but provides no clue that Face versions are coming into play:{noformat}# /opt/puppetlabs/puppet/bin/puppet foo bazBaz action called!Error: undefined method `bar' for #Error: Try 'puppet help foo baz' for usage{noformat}h3. Expected OutcomeThe error message should include the face name and version number, as provided by the {{to_s}} method of the Puppet::Interface class:{noformat}# /opt/puppetlabs/puppet/bin/puppet foo bazBaz action called!Error: undefined method `bar' for Puppet::Face[:foo, v0.0.2]:Puppet::InterfaceError: Try 'puppet help foo baz' for usage{noformat}
Add Comment