jraine/munkiserver — Issue #114: InstallItem with no valid packages causes method call on nil
Author: jraine
Created: 2011-12-09 07:08:18+00:00
State: open
Labels: bug

A package branch, which is has packages in more than one unit, is assigned to a manifest in unit A. Shortly after, the only package in unit A belonging to package branch is deleted. The InstallItem record continues to exist, because the package branch is not removed from the database.

When trying to render the view, you'll see this:

```
ActionView::Template::Error (undefined method `name' for nil:NilClass):
1: <% item_list.each do |item| %>
2:

3:	<% logger.info("A #{item.class} item has no packages: #{item.id}") if item.package.nil? %>
4:	<% if target.respond_to?(:installed?) and target.installed?(item.package) %>
5:	✓
6:	<% else %>
7:	✓
app/models/manifest/computer.rb:167:in `block in installed?'
app/models/manifest/computer.rb:166:in `each'
app/models/manifest/computer.rb:166:in `installed?'
app/views/shared/_pkg_list.html.erb:4:in `block in _app_views_shared__pkg_list_html_erb___1866911713841339946_2218861320_834819562124188415'
app/views/shared/_pkg_list.html.erb:1:in `_app_views_shared__pkg_list_html_erb___1866911713841339946_2218861320_834819562124188415'
app/helpers/application_helper.rb:16:in `pkg_list'
app/views/shared/_bundle_list.html.erb:16:in `block in _app_views_shared__bundle_list_html_erb___4305365481328443288_2201512160_2779097075586002431'
app/views/shared/_bundle_list.html.erb:1:in `_app_views_shared__bundle_list_html_erb___4305365481328443288_2201512160_2779097075586002431'
app/helpers/application_helper.rb:26:in `bundle_list'
app/views/shared/_inventory.html.erb:10:in `_app_views_shared__inventory_html_erb___1701226108272387483_2219081520_1797093712590371730'
app/helpers/application_helper.rb:31:in `inventory'
app/views/computers/show.html.erb:36:in `_app_views_computers_show_html_erb___4010407098856634051_2198987460_665026967581090888'
app/controllers/computers_controller.rb:48:in `show'
```

This will likely be addressed when #104 is resolved, but wanted to capture it in case it isn't.