Netlify CMS Deploy Previews + Large Media = Wrong SHA256 Hashes and Size For LFS references

Hi!

I have a hugo site configured with netlify cms (with netlify git gateway) and lfs. We’re using the cms authoring workflow, so that the CMS creates PRs in GitHub for each draft. When adding an image and saving the draft, netlify deploys the project and generates a preview URL which is awesome. Every image shows up and everything is nice.

However, when editing the draft and saving the draft a second time or a third time etc., netlify cms changes the SHA and size in the LFS image file, e.g.
version Git Large File Storage | Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server like GitHub.com or GitHub Enterprise.
oid sha256:XXXXXXXXXXX
size 0
The problem is that ‘XXXXXXXXXXX’ does not exist and the size is 0 now. This is shown in the PR as a commit but when looking into the Large Media tab in netlify, this sha has does not exist but the original SHA256 from the first commit on the branch for this draft post / PR is still there.

Every deployment with the wrong SHA does not show the images. However, the image URL itself returns status 200 but the HTTP response body contains no content.

So, I’m wondering. Why does the CMS change the file in the first place even though only the text is being edited? How to fix this?

And one more detail: When manually reverting the SHA + size back to the original and pushing this as a new commit on the PR, the images render correctly again.

Thanks in advance for your help! Netlify rocks!

Hi @LukasGentele, thank you for reporting this bug and sorry for the very late reply!
I see you’ve already submitted a PR for this fix(lfs): fixes lfs pointers in editorial workflow by LukasGentele · Pull Request #4613 · netlify/netlify-cms · GitHub.
I’m going to follow up on it very soon.