Skip to content

Commit ff9ac83

Browse files
authored
Fix NoMethodError when diffing manifest for new apps with features (#4941)
The remove_unspecified_app_features method was called without checking if existing_value was present, causing a NoMethodError when applying a manifest with features for a new (non-existing) app: undefined method `slice!' for nil:NilClass .../space_diff_manifest.rb:220:in `remove_unspecified_app_features'
1 parent c8604dc commit ff9ac83

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/actions/space_diff_manifest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def generate_diff(app_manifests, space)
5151

5252
remove_default_missing_fields(existing_value, key, value) if nested_attribute_exists
5353

54-
remove_unspecified_app_features(existing_value, key, value)
54+
remove_unspecified_app_features(existing_value, key, value) if existing_value.present?
5555

5656
# To preserve backwards compability, we've decided to skip diffs that satisfy this conditon
5757
next if !nested_attribute_exists && %w[disk_quota disk-quota memory].include?(key)

spec/unit/actions/space_diff_manifest_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,19 @@ module VCAP::CloudController
251251
'name' => 'new-app'
252252
},
253253
{
254-
'name' => 'newer-app'
254+
'name' => 'newer-app',
255+
'features' => {
256+
'ssh' => true
257+
}
255258
}
256259
]
257260
end
258261

259262
it 'returns the correct diff' do
260263
expect(subject).to eq([
261264
{ 'op' => 'add', 'path' => '/applications/0/name', 'value' => 'new-app' },
262-
{ 'op' => 'add', 'path' => '/applications/1/name', 'value' => 'newer-app' }
265+
{ 'op' => 'add', 'path' => '/applications/1/name', 'value' => 'newer-app' },
266+
{ 'op' => 'add', 'path' => '/applications/1/features', 'value' => { 'ssh' => true } }
263267
])
264268
end
265269
end

0 commit comments

Comments
 (0)