Fix TypeError exceptions in UpdateMergeRequestWorker
What does this MR do and why?
Previously if a commit with a long commit message (10240 bytes,
as determined by Gitaly) were processed, UpdateMergeRequestWorker
would quietly fail with a TypeError: can't quote String
while
trying to insert to the merge_request_diff_commits
table.
This appears to happen because
Gitlab::Git::Commit#fetch_body_from_gitaly
would return a
BatchLoader
instance. When the Rails PostgreSQL driver attempted to
escape the SQL, the case
statement would fail since the
BatchLoader
type did not match a String
.
To avoid these odd failures, always call to_s
to ensure the String
is rendered for long commit messages.
Relates to #410073 (closed)
How to set up and validate locally
- In a project, create a commit with a large commit message. Try 3282d21c as an example.
- In the Rails console:
[1] pry(main)> commit = project.repository.commit('3282d21cf1f1744f16010a23965e3896829ae9f5')
[2] pry(main)> ActiveRecord::Base.connection.quote(commit.message)
<snip>
[3] pry(main)> ActiveRecord::Base.connection.quote(commit.message)
TypeError: can't quote String
- Repeat this test with this branch.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.