Error 500 loading dashboard when pipelines have a nil created_at
This may be a regression in !90027 (merged) if a pipeline's created_at
is nil
?
rb(main):006:0> Ci::Pipeline.where(created_at: nil).count
D, [2022-07-29T17:17:59.349913 #1567822] DEBUG -- : (98.2ms) /*application:console,db_config_name:main*/ SELECT COUNT(*) FROM "ci_pipelines" WHERE "ci_pipelines"."created_at" IS NULL
=> 7773
irb(main):007:0> Ci::Pipeline.where(created_at: nil).last
D, [2022-07-29T17:18:03.223690 #1567822] DEBUG -- : Ci::Pipeline Load (140.8ms) /*application:console,db_config_name:main*/ SELECT "ci_pipelines".* FROM "ci_pipelines" WHERE "ci_pipelines"."created_at" IS NULL ORDER BY "ci_pipelines"."id" DESC LIMIT 1
Traceback (most recent call last):
3: from (irb):7
2: from app/models/ci/pipeline.rb:1420:in `observe_age_in_minutes'
1: from app/models/ci/pipeline.rb:1325:in `age_in_minutes'
NoMethodError (undefined method `-@' for nil:NilClass)
From https://sentry.gitlab.net/gitlab/devgitlaborg/issues/3393700/?referrer=slack:
D, [2022-07-29T17:15:21.410811 #1567822] DEBUG -- : Ci::Pipeline Load (0.6ms) /*application:console,correlation_id:29ffd580-6619-41de-8bf5-c4e9788aa1a2,endpoint_id:RootController#index,db_config_name:main*/ SELECT DISTINCT ON (sha) * FROM "ci_pipelines" WHERE "ci_pipelines"."project_id" = 242 AND ("ci_pipelines"."source" IN (1, 2, 3, 4, 5, 6, 7, 8, 10, 11) OR "ci_pipelines"."source" IS NULL) AND "ci_pipelines"."sha" = 'b7cabb1c81ea30035dd63a508a67a949c1846f4c' ORDER BY "ci_pipelines"."sha" ASC, "ci_pipelines"."id" DESC
Rendered layout layouts/dashboard.html.haml (Duration: 24.7ms | Allocations: 12621)
Completed 500 Internal Server Error in 85ms (ActiveRecord: 10.8ms | Elasticsearch: 0.0ms | Allocations: 35978)
Sending event b11d76f39b1d4e1b81a02d89df1f8cb6 to Sentry
ActionView::Template::Error (undefined method `-@' for nil:NilClass):
30:
31: .js-projects-list-holder{ data: { qa_selector: 'projects_list' } }
32: - if any_projects?(projects)
33: - load_pipeline_status(projects) if pipeline_status
34: - load_max_project_member_accesses(projects) # Prime cache used in shared/projects/project view rendered below
35: %ul.projects-list{ class: css_classes }
36: - projects.each_with_index do |project, i|
app/models/ci/pipeline.rb:1325:in `age_in_minutes'
app/models/ci/pipeline.rb:1420:in `observe_age_in_minutes'
app/models/ci/pipeline.rb:444:in `latest_pipeline_per_commit'
app/models/ci/commit_with_pipeline.rb:23:in `block in lazy_latest_pipeline'
app/models/ci/commit_with_pipeline.rb:38:in `block in latest_pipeline'
app/models/ci/commit_with_pipeline.rb:34:in `fetch'
app/models/ci/commit_with_pipeline.rb:34:in `latest_pipeline'
app/models/ci/commit_with_pipeline.rb:52:in `status'
app/models/commit.rb:147:in `status'
lib/gitlab/cache/ci/project_pipeline_status.rb:71:in `load_from_project'
lib/gitlab/cache/ci/project_pipeline_status.rb:56:in `load_status'
lib/gitlab/cache/ci/project_pipeline_status.rb:23:in `block in load_in_batch_for_projects'
lib/gitlab/cache/ci/project_pipeline_status.rb:21:in `load_in_batch_for_projects'
app/helpers/projects_helper.rb:195:in `load_pipeline_status'
app/views/shared/projects/_list.html.haml:33
app/views/dashboard/projects/_projects.html.haml:1
app/views/dashboard/projects/index.html.haml:16
app/controllers/application_controller.rb:142:in `render'
app/controllers/dashboard/projects_controller.rb:64:in `block in render_projects'
lib/gitlab/gitaly_client.rb:307:in `allow_n_plus_1_calls'
app/controllers/dashboard/projects_controller.rb:63:in `render_projects'
app/controllers/dashboard/projects_controller.rb:23:in `block (2 levels) in index'
app/controllers/dashboard/projects_controller.rb:21:in `index'
app/controllers/root_controller.rb:25:in `block in index'
lib/gitlab/gitaly_client.rb:307:in `allow_n_plus_1_calls'
app/controllers/root_controller.rb:23:in `index'
app/controllers/application_controller.rb:531:in `set_current_admin'
app/controllers/application_controller.rb:520:in `set_session_storage'
lib/gitlab/i18n.rb:107:in `with_locale'
lib/gitlab/i18n.rb:113:in `with_user_locale'
app/controllers/application_controller.rb:516:in `set_locale'
app/controllers/concerns/sessionless_authentication.rb:41:in `sessionless_bypass_admin_mode!'
app/controllers/application_controller.rb:510:in `set_current_context'
lib/gitlab/middleware/memory_report.rb:13:in `call'
lib/gitlab/middleware/speedscope.rb:13:in `call'
lib/gitlab/database/load_balancing/rack_middleware.rb:23:in `call'
lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:21:in `call'
lib/gitlab/middleware/query_analyzer.rb:11:in `block in call'
lib/gitlab/database/query_analyzer.rb:37:in `within'
lib/gitlab/middleware/query_analyzer.rb:11:in `call'
lib/gitlab/middleware/multipart.rb:173:in `call'
lib/gitlab/middleware/read_only/controller.rb:50:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
lib/gitlab/middleware/request_context.rb:21:in `call'
lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'
config/initializers/fix_local_cache_middleware.rb:11:in `call'
lib/gitlab/middleware/compressed_json.rb:26:in `call'
lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:77:in `call'
(irb):5:in `block in irb_binding'
lib/gitlab/profiler.rb:152:in `with_user'
(irb):5:in `irb_binding'
/cc: @grzesiek
Edited by Stan Hu