Chef: Knife upload: bad error message when a recipe has a syntax error

Created on 6 Jun 2018  路  3Comments  路  Source: chef/chef

Description

When uploading a file with a syntax error to chef-zero, the error message has an empty filename and doesn't actually display the syntax error.

ChefDK Version

Tested on both:

  1. Remote ec2 machine running chef-zero: Chef Development Kit Version: 3.0.36
  2. MacOS running: Chef 13.8.5

Platform Version

  1. Amazon linux, latest AMI
  2. MacOS High Sierra

Replication Case

Start a chef-zero instance and create a cookbook with a single recipe with the following content:

cookbook_file "blah" do
  source "blah"
  mode "0644"
do

Try to upload the cookbook to the chef-zero server:

knife upload cookbooks/ --server-url http://localhost:<port> --chef-repo-path . --user dev -V

Expected:

Output similar to ruby -c : recipes/test.rb:4: syntax error, unexpected keyword_do_block, expecting keyword_end

Actual:

No indication of which cookbook or recipe had the error, and no syntax error either:

INFO: Validating ruby files
FATAL: Cookbook file  has a ruby syntax error:
knife Low Sustaining Backlog

Most helpful comment

Hi @Vasu1105, the problem is not the syntax error, it is that chef zero suppresses the error message, so the user has no idea where the problem is. The bad code is just a way to reproduce the problem.

All 3 comments

cookbook_file "blah" do
  source "blah"
  mode "0644"
do

Looks a syntax error here it should be

cookbook_file "blah" do
  source "blah"
  mode "0644"
end

Closing it as it looks more of wrong syntax in the recipe as explained above. Feel free to open if there still an issue.

Hi @Vasu1105, the problem is not the syntax error, it is that chef zero suppresses the error message, so the user has no idea where the problem is. The bad code is just a way to reproduce the problem.

Was this page helpful?
0 / 5 - 0 ratings