Summary
On a stack's show page, every entry in the Previous Deploys list (including Shipit::Deploy and Shipit::Rollback records) is linked to tasks#show (/stacks/:id/tasks/:task_id). Clicking on a "deploy" or "rollback" task that way raises:
ActionView::Template::Error (undefined method 'id' for nil)
app/views/shipit/tasks/show.html.erb:2
so clicking any deploy in Previous Deploys returns a 500.
Note that overriding the link and visiting the same record at /stacks/:id/deploys/:id works fine.
Steps to reproduce
- Open a stack that has previous deploys.
- Click a deploy (or rollback) in the Previous Deploys list — it links to
/stacks/:id/tasks/:task_id.
- 500:
undefined method 'id' for nil at app/views/shipit/tasks/show.html.erb:2.
Root cause
tasks/show.html.erb renders the task title with @task.definition.id:
<%= @task.active? ? "executing" : "executed" %> <%= @task.definition.id %>
definition is a serialized column populated only for generic shipit.yml tasks.
Deploys and rollbacks don't seem to ever have one (Stack#build_deploy doesn't set it).
This view is only meant for generic tasks — deploys/rollbacks have their own deploys/show and deploys/_deploy. The reason they now reach tasks#show is the deploy list in stacks/show.html.erb:
<%= render partial: 'shipit/tasks/task', collection: @tasks %>
This forces every record through shipit/tasks/_task, which links via stack_task_path → tasks#show. Previously the list used polymorphic rendering:
which dispatched each record via to_partial_path: Shipit::Deploy → shipit/deploys/_deploy and Shipit::Rollback (to_partial_path overridden to 'deploys/deploy') → the same deploy partial, both linking to deploys#show. Only generic tasks rendered tasks/_task.
The change came in 793e1d5, which replaced render @tasks with the explicit single-partial form.
That seemed to have suppressed the implicit-render warning but loses the per-type partial dispatch for the STI subclasses.
Still present on main / 0.45.1.
Possible fixes
- Restore polymorphic rendering (
render @tasks) for the deploy list in stacks/show.html.erb; or
- Keep explicit rendering but dispatch per type (
deploys/_deploy for Deploy/Rollback, tasks/_task for generic tasks); or
- Make
tasks/show.html.erb tolerate a nil definition (e.g. fall back to @task.title) so a deploy routed there doesn't crash.
Environment
- shipit-engine 0.45.1 (also reproducible on 0.44.2)
- Rails 8.1.3
Summary
On a stack's show page, every entry in the Previous Deploys list (including
Shipit::DeployandShipit::Rollbackrecords) is linked totasks#show(/stacks/:id/tasks/:task_id). Clicking on a "deploy" or "rollback" task that way raises:so clicking any deploy in Previous Deploys returns a 500.
Note that overriding the link and visiting the same record at
/stacks/:id/deploys/:idworks fine.Steps to reproduce
/stacks/:id/tasks/:task_id.undefined method 'id' for nilatapp/views/shipit/tasks/show.html.erb:2.Root cause
tasks/show.html.erbrenders the task title with@task.definition.id:definitionis a serialized column populated only for genericshipit.ymltasks.Deploys and rollbacks don't seem to ever have one (
Stack#build_deploydoesn't set it).This view is only meant for generic tasks — deploys/rollbacks have their own
deploys/showanddeploys/_deploy. The reason they now reachtasks#showis the deploy list instacks/show.html.erb:This forces every record through
shipit/tasks/_task, which links viastack_task_path→tasks#show. Previously the list used polymorphic rendering:which dispatched each record via
to_partial_path:Shipit::Deploy→shipit/deploys/_deployandShipit::Rollback(to_partial_pathoverridden to'deploys/deploy') → the same deploy partial, both linking todeploys#show. Only generic tasks renderedtasks/_task.The change came in 793e1d5, which replaced
render @taskswith the explicit single-partial form.That seemed to have suppressed the implicit-render warning but loses the per-type partial dispatch for the STI subclasses.
Still present on
main/ 0.45.1.Possible fixes
render @tasks) for the deploy list instacks/show.html.erb; ordeploys/_deployforDeploy/Rollback,tasks/_taskfor generic tasks); ortasks/show.html.erbtolerate a nildefinition(e.g. fall back to@task.title) so a deploy routed there doesn't crash.Environment