Push email notifications stopped showing diffs for text files larger than 512 KB
Summary
After upgrading from 18.8.4.-ce.0 to 18.9.0-ce.0, notification emails generated by the "email on push" integration have stopped including diffs for text files larger than 512 KB, instead showing "No preview for this file type".
This is independent of the size of the diff and only depends on the size of the file after the commit. Files up to 524288 Bytes = 2**19 Bytes = 512 KB work fine.
The diff renders fine in the Web UI, but is not included in the notification email.
The issue is reproducible on gitlab.com with this test repository: https://gitlab.com/lweberefn1/test-email-on-push
Steps to reproduce
- Create new repository (or use below test repository)
- Enable "Email on push" integration
- Create a file larger than 512 KB (for example, by running the python script in the test repository as
python3 gen-files.py 524289) - git add, git commit, git push
- Introduce a change in this file, keeping the file size at or above 524288 Bytes (a small change is enough)
- Commit and push
- Observe the notification email showing "No preview for this file type"
Example Project
Example project: https://gitlab.com/lweberefn1/test-email-on-push
Example commit: https://gitlab.com/lweberefn1/test-email-on-push/-/commit/84db76b0b2d297cc9fa5cdfd8470e90a272e26dd
What is the current bug behavior?
For text files larger than 512 KB, "No preview for this file type" is shown instead of the diff.
What is the expected correct behavior?
The diff should be shown (unless the diff itself is too large, which would be indicated by the message "The diff for this file was not included because it is too large.").
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Possible fixes
The issue seems to be similar to #20838 (closed) but with a much lower file size limit.
I’ve verified that also in this case, the problem is that blob.readable_text? (https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/app/models/blob.rb#L216) is false due to truncated? being true, although I was unable to find es the exact problem leading to the 512 KB limit.
