[git lfs] web interface displays lfs metadata instead of real file #3472

Closed
opened 2025-11-02 05:13:53 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @schmittlauch on GitHub (Jun 14, 2019).

  • Gitea version (or commit ref): 1.8.2
  • Git version: 1.12.5
  • Operating system: Linux (openSUSE)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No, reason: cannot even push a git lfs repo:
batch response: Repository or object not found: https://try.gitea.io/schmittlauch/lfs_test.git/info/lfs/objects/batch                                                                        
Check that it exists and that you have proper access to it
  • Not relevant
  • Log gist:

Description

For repositories containing files stored in git lfs buckets, the gitea web interface does not display the actual file but only the intermediate metadata file of git lfs.

Screenshots

Screenshot_20190615_015713

Originally created by @schmittlauch on GitHub (Jun 14, 2019). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.8.2 - Git version: 1.12.5 - Operating system: Linux (openSUSE) - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No, reason: cannot even push a git lfs repo: ``` batch response: Repository or object not found: https://try.gitea.io/schmittlauch/lfs_test.git/info/lfs/objects/batch Check that it exists and that you have proper access to it ``` - [ ] Not relevant - Log gist: ## Description For repositories containing files stored in git lfs buckets, the gitea web interface does not display the actual file but only the intermediate metadata file of git lfs. ## Screenshots ![Screenshot_20190615_015713](https://user-images.githubusercontent.com/1479555/59544312-16b9c480-8f11-11e9-9a8c-d15755839ab1.png)
Author
Owner

@zeripath commented on GitHub (Jun 15, 2019):

First of all LFS is not available on try.gitea.io. That's why the push fails there.

@zeripath commented on GitHub (Jun 15, 2019): First of all LFS is not available on try.gitea.io. That's why the push fails there.
Author
Owner

@zeripath commented on GitHub (Jun 15, 2019):

Ok so assuming that your Gitea is actually running as an LFS server. This should not be happening.

Let's look at view.go the rendering of a file is handled:

76e8eec3d9/routers/repo/view.go (L207-L216)

Where it opens a blob and then reads some of it in to a buffer checking if it's a text file:

76e8eec3d9/routers/repo/view.go (L226-L230)

If it's a text file and LFS is enabled it will try to see if it matches an LFS file:

76e8eec3d9/routers/repo/view.go (L234-L248)

And then will switch to use that LFS files contents. So you should never see the LFS pointer once it has matched.

@zeripath commented on GitHub (Jun 15, 2019): Ok so assuming that your Gitea is actually running as an LFS server. This should not be happening. Let's look at view.go the rendering of a file is handled: https://github.com/go-gitea/gitea/blob/76e8eec3d9b9289df33e1fa5c83dac22662029cf/routers/repo/view.go#L207-L216 Where it opens a blob and then reads some of it in to a buffer checking if it's a text file: https://github.com/go-gitea/gitea/blob/76e8eec3d9b9289df33e1fa5c83dac22662029cf/routers/repo/view.go#L226-L230 If it's a text file and LFS is enabled it will try to see if it matches an LFS file: https://github.com/go-gitea/gitea/blob/76e8eec3d9b9289df33e1fa5c83dac22662029cf/routers/repo/view.go#L234-L248 And then will switch to use that LFS files contents. So you should never see the LFS pointer once it has matched.
Author
Owner

@zeripath commented on GitHub (Jun 15, 2019):

GetLFSMetaObjectByOid looks like:

76e8eec3d9/models/lfs.go (L89-L105)

@zeripath commented on GitHub (Jun 15, 2019): `GetLFSMetaObjectByOid` looks like: https://github.com/go-gitea/gitea/blob/76e8eec3d9b9289df33e1fa5c83dac22662029cf/models/lfs.go#L89-L105
Author
Owner

@zeripath commented on GitHub (Jun 15, 2019):

Ok now we have the code context we can try to work out what's going wrong.

Clearly your file above is a text file that appears to be an LFS pointer file.

So that leaves 2 possibilities:

  • You don't have LFS started on your Gitea.
  • The GetLFSMetaObjectByOid fails because the LFS file is not associated with that repository.

So are you sure you've pushed your LFS file to Gitea?

How did you get your LFS file into this repository? Was it through a merge from a fork? There's a corollary issue to #732 whereby if you can merge prs with LFS files, those LFS files will not be associated with the base repository. This will be finally fixed by #7082.

My WIP pr #7199 will add some LFS management features to the repository settings - allowing you to search a repository for missing LFS files.

@zeripath commented on GitHub (Jun 15, 2019): Ok now we have the code context we can try to work out what's going wrong. Clearly your file above is a text file that appears to be an LFS pointer file. So that leaves 2 possibilities: * You don't have LFS started on your Gitea. * The `GetLFSMetaObjectByOid` fails because the LFS file is not associated with that repository. So are you sure you've pushed your LFS file to Gitea? How did you get your LFS file into this repository? Was it through a merge from a fork? There's a corollary issue to #732 whereby if you can merge prs with LFS files, those LFS files will not be associated with the base repository. This will be finally fixed by #7082. My WIP pr #7199 will add some LFS management features to the repository settings - allowing you to search a repository for missing LFS files.
Author
Owner

@schmittlauch commented on GitHub (Jun 15, 2019):

Ok so assuming that your Gitea is actually running as an LFS server. This should not be happening.

I ran into an interesting edge case: First of all, git lfs was not enabled on my gitea instance. Sorry, my bad, i wasn't aware of the necessity of manually enabling it.
I got no error message while pushing though, so I had no real reason to assume thinks not working.
The reason for that is my special setup: I added my gitea repo as a 2nd url to an existing remote (gitlab). git lfs already had pushed the files once for this remote, but only to the storage available under the 1st url. So the lfs files never reached my gitea repo, neither giving gitea the chance to resolve the pointer files nor returning an error message.

Closing this as I'm not sure whether gitea can do anything about this, it's probably more of a git lfs bug/ quirk.

@schmittlauch commented on GitHub (Jun 15, 2019): > Ok so assuming that your Gitea is actually running as an LFS server. This should not be happening. I ran into an interesting edge case: First of all, git lfs was *not* enabled on my gitea instance. Sorry, my bad, i wasn't aware of the necessity of manually enabling it. I got no error message while pushing though, so I had no real reason to assume thinks not working. The reason for that is my special setup: I added my gitea repo as a 2nd url to an existing remote (gitlab). git lfs already had pushed the files once for this remote, but only to the storage available under the 1st url. So the lfs files never reached my gitea repo, neither giving gitea the chance to resolve the pointer files nor returning an error message. Closing this as I'm not sure whether gitea can do anything about this, it's probably more of a git lfs bug/ quirk.
Author
Owner

@zeripath commented on GitHub (Jun 15, 2019):

Yeah unfortunately there's no way for Gitea to divine where you stored your LFS files as far as I understand it. I don't think it's ever sent across with a push.

@zeripath commented on GitHub (Jun 15, 2019): Yeah unfortunately there's no way for Gitea to divine where you stored your LFS files as far as I understand it. I don't think it's ever sent across with a push.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3472