Fix 500 error in Commits API when the repository is empty
What does this MR do and why?
Contributes to #452488 (closed)
Problem
Gitaly started returning an internal error, when the user requests commits of the empty repository: gitaly!6590 (merged). Rails doesn't handle it and returns a 500 error.
Solution
Add a temporary handler for this error, before the Gitaly code is updated.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Create a project with an empty repository (without README.md)
- Visit
http://127.0.0.1:3000/api/v4/projects/<project_id>/repository/commits
- You should see an empty array response instead of an internal error.
Merge request reports
Activity
changed milestone to %16.11
added backend bugfunctional groupsource code labels
assigned to @vyaklushin
added typebug label
added Category:Source Code Management devopscreate sectiondev labels
mentioned in issue #452488 (closed)
Reviewer roulette
Category Reviewer Maintainer backend @praba.m7n
(UTC+2, same timezone as author)
@rymai
(UTC+2, same timezone as author)
Please check reviewer's status!
Please refer to documentation page for guidance on how you can benefit from the Reviewer Roulette, or use the GitLab Review Workload Dashboard to find other available reviewers.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
Dangeradded 1 commit
- 7d24d374 - Fix 500 error in Commits API when the repository is empty
- Resolved by Pedro Pombeiro
Hi @Quintasan!
Can you please review this fix?
requested review from @Quintasan
requested review from @pedropombeiro
added pipeline:mr-approved label
- Resolved by Pedro Pombeiro
@Quintasan
, thanks for approving this merge request.This is the first time the merge request has been approved. To ensure we don't only run predictive pipelines, and we don't break
master
, a new pipeline will be started shortly.Please wait for the pipeline to start before resolving this discussion and set auto-merge for the new pipeline. See merging a merge request for more details.
enabled an automatic merge when the pipeline for 27bbafc2 succeeds
E2E Test Result Summary
allure-report-publisher
generated test report!e2e-test-on-gdk:
test report for 02e353a5expand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Plan | 51 | 0 | 2 | 0 | 53 | ✅ | | Verify | 35 | 0 | 1 | 0 | 36 | ✅ | | Package | 24 | 0 | 6 | 0 | 30 | ✅ | | Govern | 66 | 0 | 0 | 0 | 66 | ✅ | | Create | 77 | 0 | 9 | 0 | 86 | ✅ | | Data Stores | 31 | 0 | 0 | 0 | 31 | ✅ | | Monitor | 7 | 0 | 0 | 0 | 7 | ✅ | | Release | 5 | 0 | 0 | 0 | 5 | ✅ | | Analytics | 2 | 0 | 0 | 0 | 2 | ✅ | | Manage | 0 | 0 | 1 | 0 | 1 | ➖ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 298 | 0 | 19 | 0 | 317 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
e2e-package-and-test:
test report for 02e353a5expand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Create | 570 | 0 | 66 | 10 | 636 | ✅ | | Plan | 8 | 0 | 0 | 0 | 8 | ✅ | | Data Stores | 4 | 0 | 0 | 0 | 4 | ✅ | | Govern | 6 | 0 | 0 | 0 | 6 | ✅ | | Monitor | 8 | 0 | 0 | 0 | 8 | ✅ | | Package | 0 | 0 | 2 | 0 | 2 | ➖ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 596 | 0 | 68 | 10 | 664 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
reset approvals from @Quintasan by pushing to the branch
Hi @pedropombeiro!
Can you please review this fix and set an auto-merge again?The previous attempt failed because of
rspec::undercoverage
test. I've added a new test to fix this failure.enabled an automatic merge when the pipeline for 78b98a71 succeeds
mentioned in commit 457909e1
mentioned in incident gitlab-org/quality/engineering-productivity/review-apps-broken-incidents#1520 (closed)
added workflowstaging-canary label
added workflowcanary label and removed workflowstaging-canary label
171 171 commits = Commit.decorate(commits, container) if commits.present? 172 172 173 173 CommitCollection.new(container, commits, ref) 174 rescue Gitlab::Git::CommandError => e 175 # Temporary fix to address a new Gitaly internal error: https://gitlab.com/gitlab-org/gitlab/-/issues/452488 176 return CommitCollection.new(container, [], ref) if e.message.include?('listing commits failed') @vyaklushin this is somewhat dangerous as this message matches all unknown error that might cause listing commits to fail. While there is a regression in #452488 (closed), this workaround will cause most errors to be ignored. I think we should prioritize fixin the actual issue in Gitaly and revert this as this leads to incorrect results.
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
added workflowpost-deploy-db-staging label and removed workflowproduction label
added releasedcandidate label
mentioned in merge request !148979 (merged)
mentioned in merge request kubitus-project/kubitus-installer!2945 (merged)
added releasedpublished label and removed releasedcandidate label
added pipelinetier-3 label