{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef/issues/4815","repository_url":"https://api.github.com/repos/chef/chef","labels_url":"https://api.github.com/repos/chef/chef/issues/4815/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/4815/comments","events_url":"https://api.github.com/repos/chef/chef/issues/4815/events","html_url":"https://github.com/chef/chef/issues/4815","id":146995662,"number":4815,"title":"Uploading an encrypted data bag to Chef server fails","user":{"login":"tpetchel","id":7142397,"avatar_url":"https://avatars.githubusercontent.com/u/7142397?v=3","gravatar_id":"","url":"https://api.github.com/users/tpetchel","html_url":"https://github.com/tpetchel","followers_url":"https://api.github.com/users/tpetchel/followers","following_url":"https://api.github.com/users/tpetchel/following{/other_user}","gists_url":"https://api.github.com/users/tpetchel/gists{/gist_id}","starred_url":"https://api.github.com/users/tpetchel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpetchel/subscriptions","organizations_url":"https://api.github.com/users/tpetchel/orgs","repos_url":"https://api.github.com/users/tpetchel/repos","events_url":"https://api.github.com/users/tpetchel/events{/privacy}","received_events_url":"https://api.github.com/users/tpetchel/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/chef/chef/labels/Exclude%20From%20Changelog","name":"Exclude From Changelog","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-08T17:58:19Z","updated_at":"2016-04-20T16:39:13Z","closed_at":null,"body":"## Description\r\n\r\nUploading an encrypted data bag to Chef server fails with this error:\r\n\r\n```\r\nERROR: Chef::Exceptions::InvalidDataBagItemID: Data Bag items must have an id matching /^[\\.\\-[:alnum:]_]+$/, you gave: nil\r\n```\r\n\r\nThis issue blocks our Learn Chef tutorials. Users reported the issue on the RHEL and Ubuntu flavors of the same tutorial:\r\n \r\nhttps://learn.chef.io/manage-a-web-app/rhel/run-your-web-application-on-a-node/#comment-2597692112\r\n\r\nhttps://learn.chef.io/manage-a-web-app/ubuntu/run-your-web-application-on-a-node/#comment-2609047548\r\n\r\nThe user in the second thread worked around the issue by manually adding the `id` field to the encrypted data bag item's .json file.\r\n\r\nI can repo this using Chef DK 0.12.0. I'm almost certain that it does not repro from 0.10.0.\r\n\r\n## Chef Version\r\n\r\n```\r\n$ chef --version\r\nChef Development Kit Version: 0.12.0\r\nchef-client version: 12.6.0\r\nberks version: 4.3.0\r\nkitchen version: ERROR\r\n```\r\n\r\n## Platform Version\r\n\r\nApplies to all platforms. Can repro from Windows 8.1 and Mac OS workstations.\r\n\r\n## Replication Case\r\n\r\nI believe this bug would apply to uploading any encrypted data bag item to the Chef server, but here's a quick way to repo. `knife` needs to be configured to communicate with a Chef server.\r\n\r\nPerform [step 2](https://learn.chef.io/manage-a-web-app/rhel/bring-up-the-web-app-using-test-kitchen/#step2) from the tutorial's quick start page to set up the encrypted data bag locally.\r\n\r\nPerform [step 3](https://learn.chef.io/manage-a-web-app/rhel/run-your-web-application-on-a-node/#step3) on this page to upload the data bag to the Chef server.\r\n\r\n## Client Output\r\n\r\n```\r\n$ knife data bag from file database_passwords mysql_customers.json\r\nERROR: Chef::Exceptions::InvalidDataBagItemID: Data Bag items must have an id matching /^[\\.\\-[:alnum:]_]+$/, you gave: nil\r\n```\r\n\r\n## Stacktrace\r\n\r\n```\r\n$ knife data bag from file database_passwords mysql_customers.json -VV\r\nINFO: Using configuration from /Users/thomaspetchel/learn-chef/.chef/knife.rb\r\n/Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/data_bag_item.rb:44:in `validate_id!': Data Bag items must have an id matching /^[\\.\\-[:alnum:]_]+$/, you gave: nil (Chef::Exceptions::InvalidDataBagItemID)\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/data_bag_item.rb:73:in `validate_id!'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/data_bag_item.rb:80:in `raw_data='\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife/data_bag_from_file.rb:94:in `block in load_data_bag_items'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife/data_bag_from_file.rb:85:in `each'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife/data_bag_from_file.rb:85:in `load_data_bag_items'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife/data_bag_from_file.rb:58:in `run'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife.rb:419:in `block in run_with_pretty_exceptions'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/local_mode.rb:44:in `with_server_connectivity'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife.rb:418:in `run_with_pretty_exceptions'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/knife.rb:212:in `run'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/knife.rb:142:in `run'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/knife:25:in `<top (required)>'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/bin/knife:23:in `load'\r\n\tfrom /Users/thomaspetchel/.rbenv/versions/2.1.1/bin/knife:23:in `<main>'\r\n```"},"comment":{"url":"https://api.github.com/repos/chef/chef/issues/comments/212506386","html_url":"https://github.com/chef/chef/issues/4815#issuecomment-212506386","issue_url":"https://api.github.com/repos/chef/chef/issues/4815","id":212506386,"user":{"login":"bwhitacrejha","id":14998254,"avatar_url":"https://avatars.githubusercontent.com/u/14998254?v=3","gravatar_id":"","url":"https://api.github.com/users/bwhitacrejha","html_url":"https://github.com/bwhitacrejha","followers_url":"https://api.github.com/users/bwhitacrejha/followers","following_url":"https://api.github.com/users/bwhitacrejha/following{/other_user}","gists_url":"https://api.github.com/users/bwhitacrejha/gists{/gist_id}","starred_url":"https://api.github.com/users/bwhitacrejha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwhitacrejha/subscriptions","organizations_url":"https://api.github.com/users/bwhitacrejha/orgs","repos_url":"https://api.github.com/users/bwhitacrejha/repos","events_url":"https://api.github.com/users/bwhitacrejha/events{/privacy}","received_events_url":"https://api.github.com/users/bwhitacrejha/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T16:39:13Z","updated_at":"2016-04-20T16:39:13Z","body":"I am able to reproduce this error simply by attempting to upload a data_bag.  With or without encryption.  Here are my current versions:\r\n\r\nChef Development Kit Version: 0.10.0\r\nchef-client version: 12.5.1\r\nberks version: 4.0.1\r\nkitchen version: 1.4.2\r\n\r\nAlso note that when I created the data bag via Knife, I had to log out of the Chef Server and back in for the data bag to even show up in the GUI.  Knife however was able to list it immediately.\r\n"}}