You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Images committed with Git LFS show as broken images in pull request descriptions #35445
I searched existing issues and did not find a duplicate.
I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
In a github.com pull request description, embed an image tracked by Git LFS. For example, this public file (the repository tracks *.png with LFS): 
Open the pull request in the pull request panel.
Expected behavior
The image renders, as it does on GitHub.
Actual behavior
A broken image. gitHubMediaUrl maps blob/…?raw=true to raw.githubusercontent.com, which returns the LFS pointer, not the file:
$ curl -sS -w '%{http_code} %{content_type} %{size_download}\n' \
https://raw.githubusercontent.com/IDEDARY/Bevypunk/HEAD/art/movies/intro_frames/1_background.png
version https://git-lfs.github.com/spec/v1
oid sha256:5a8f16132efe3eb67a8dea335571beac2745147010dabcedde78dbe708e6bccd
size 38688
200 text/plain; charset=utf-8 130
sourceControlMediaResponse serves those 130 bytes as image/png, the type of the file name, so the image fails to decode. The Contents API returns the pointer too, so GitHub Enterprise Server files read through it (#35439) have the same gap.
Two routes return the real file:
https://media.githubusercontent.com/media/<owner>/<repo>/<ref>/<path> with the token. github.com only, and it returns 404 for a file that is not in LFS.
The Git LFS batch API, POST https://<host>/<owner>/<repo>.git/info/lfs/objects/batch, which every GitHub host serves. It accepts the gh token with Basic or Bearer auth.
A tested fix is ready on a branch: when a repository file reads back as a pointer (at most 1024 bytes and starting with the spec line), the server asks the batch API for the object and streams it. For the file above it returns the 38,688-byte PNG whose SHA-256 matches the pointer's oid.
Activity