Add nil check for schedule.project in profiles/accounts/show.html.haml to prevent 500 errors
Summary
The user account settings page (/-/profile/account) crashes with a 500 error when displaying scheduled pipelines owned by a user if any of those schedules have a project_id pointing to a non-existant record. This occurs because the view attempts to call schedule.project.full_path without checking if the project exists.
Root Cause
Pipeline schedules use loose foreign keys for the project_id column with async_delete cleanup:
ci_pipeline_schedules:
- table: projects
column: project_id
on_delete: async_delete
This means there's a window of time between project deletion and schedule cleanup where orphaned schedules exist. During this window, the account settings page will crash for users who own these orphaned schedules.
Current Behavior
When a user accesses their account settings page and owns a pipeline schedule with project_id: nil, the page crashes with:
undefined method 'full_path' for nil:NilClass
app/views/profiles/accounts/show.html.haml:83
Expected Behavior
The page should gracefully handle orphaned schedules by either:
- Filtering them out in the controller query
- Adding a nil check in the view before rendering
- Both (defense in depth)
Proposed Solution
Option 2: Guard in view
- current_user.pipeline_schedules.each do |schedule|
- next if schedule.project.nil?
/ render schedule
Related Issue
This issue was discovered in gitlab-com/request-for-help#3686 where a user had orphaned schedules causing their account settings page to crash.
Impact
Users who own orphaned pipeline schedules cannot access their account settings page until the async cleanup completes or the orphaned schedules are manually deleted.