the gitea API return wrong url for submodule files #10159

Closed
opened 2025-11-02 08:59:54 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @c-my on GitHub (Jan 27, 2023).

Originally assigned to: @Zettat123 on GitHub.

Description

There is a submodule in my repo (https://try.gitea.io/c-my/test).

If I request the api endpoint “https://try.gitea.io/api/v1/repos/c-my/test/git/trees/main?recursive=true”, there will be following contents in the response:

...
    {
      "path": "themes/butterfly",
      "mode": "160000",
      "type": "commit",
      "size": 0,
      "sha": "08fabdc2d14c3f6d52f0193c709313eed21b5c07",
      "url": "https://try.gitea.io/api/v1/repos/c-my/test/git/blobs/08fabdc2d14c3f6d52f0193c709313eed21b5c07"
    }
...

But I got 404 error when requesting the url "08fabdc2d1". Because the real url should be https://github.com/jerryc127/hexo-theme-butterfly/commit/08fabdc2d14c3f6d52f0193c709313eed21b5c07.

The link is correct in web UI but not in API, so I think this can/should be fixed.

Gitea Version

1.19.0+dev-356-g4f8c0eba9

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

https://try.gitea.io/

Database

None

Originally created by @c-my on GitHub (Jan 27, 2023). Originally assigned to: @Zettat123 on GitHub. ### Description There is a submodule in my repo (https://try.gitea.io/c-my/test). If I request the api endpoint “https://try.gitea.io/api/v1/repos/c-my/test/git/trees/main?recursive=true”, there will be following contents in the response: ```json ... { "path": "themes/butterfly", "mode": "160000", "type": "commit", "size": 0, "sha": "08fabdc2d14c3f6d52f0193c709313eed21b5c07", "url": "https://try.gitea.io/api/v1/repos/c-my/test/git/blobs/08fabdc2d14c3f6d52f0193c709313eed21b5c07" } ... ``` But I got 404 error when requesting the url "https://try.gitea.io/api/v1/repos/c-my/test/git/blobs/08fabdc2d14c3f6d52f0193c709313eed21b5c07". Because the real url should be `https://github.com/jerryc127/hexo-theme-butterfly/commit/08fabdc2d14c3f6d52f0193c709313eed21b5c07`. The link is correct in web UI but not in API, so I think this can/should be fixed. ### Gitea Version 1.19.0+dev-356-g4f8c0eba9 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? https://try.gitea.io/ ### Database None
GiteaMirror added the type/bug label 2025-11-02 08:59:54 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10159