summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorlamont-granquist <lamont@scriptkiddie.org>2013-06-12 13:49:03 -0700
committerlamont-granquist <lamont@scriptkiddie.org>2013-06-12 13:49:03 -0700
commit439980b12ed78eb5f61c52cf0d23d4a9205d1011 (patch)
treeffe99102868ece4f15692dfc4775fd31cdc0ffa6 /lib/chef
parentde4d8e66be3dee3ccd9ac027e6332e0eb37f532e (diff)
parentc0516c7cece925a44e45f1fed4c57cebd671c045 (diff)
downloadchef-439980b12ed78eb5f61c52cf0d23d4a9205d1011.tar.gz
Merge pull request #812 from opscode/lcg/CHEF-3307-empty-string-fix
CHEF-3307: metadata.name can be empty, which is truthy
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/cookbook/metadata.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 0cd740ea8f..0c03b25b00 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -468,6 +468,15 @@ class Chef
@groupings = o[GROUPINGS] if o.has_key?(GROUPINGS)
@recipes = o[RECIPES] if o.has_key?(RECIPES)
@version = o[VERSION] if o.has_key?(VERSION)
+ #
+ # XXX: When a client (berkshelf in particular) uploads metadata without a name field, the hosted chef
+ # ruby server will subsequently return empty string ("") for the metadata.name. In erchef uploading
+ # metadata without a name field will simply not store or retrieve a name field so we get @name = nil.
+ # During the migration from ruby to erchef, metadata.name of "" was migrated faithfully even though it
+ # fails validation, and erchef will return this, so we still have to handle this case unless the
+ # database is sanitized to remove metadata.name == "".
+ #
+ @name = nil if !@name.nil? && @name.empty?
self
end