Skip to content

Commit

Permalink
(PUP-11928) Give more specific error messages for /puppet/v3/tasks API
Browse files Browse the repository at this point in the history
Currently, when a task is omitted due to a failure, Puppet Server logs an
exception with a generic error message and provides no details on how to
resolve the error: `ERROR [qtp1527520408-905] [puppetserver] Puppet Failed to
validate task`

This commit removes the generic message that overrides the original error message in
the rescued error. Instead, the rescued error message is logged.
  • Loading branch information
AriaXLi committed Sep 7, 2023
1 parent 5e1cea2 commit 3973318
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/info_service/task_information_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.tasks_per_environment(environment_name)
task.validate
{:module => {:name => task.module.name}, :name => task.name, :metadata => task.metadata}
rescue Puppet::Module::Task::Error => err
Puppet.log_exception(err, 'Failed to validate task')
Puppet.log_exception(err)
nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/info_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
:content => metadata.to_json}]]})
File.write("#{modpath}/#{mod_name}/tasks/atask.json", "NOT JSON")

expect(Puppet).to receive(:send_log).with(:err, 'Failed to validate task')
expect(Puppet).to receive(:send_log).with(:err, /unexpected token at 'NOT JSON'/)

@tasks = Puppet::InfoService.tasks_per_environment(env_name)
expect(@tasks.map{|t| t[:name]}).to contain_exactly('test1::btask', 'test1::ctask')
Expand Down

0 comments on commit 3973318

Please sign in to comment.