Issue with paging on /repos/{owner}/{repo}/git/trees/{sha} api #4529

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

Originally created by @bhalbright on GitHub (Dec 21, 2019).

  • Gitea version (or commit ref): 4f42e03
  • Git version: 2.19.1.windows.1
  • Operating system: Windows 10
  • Database (use [x]):
    • PostgreSQL
    • [ x] MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • [ x] Not relevant
  • Log gist:
    2019/12/20 22:25:14 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: index out of range
    E:/Go/src/runtime/panic.go:44 (0x42fbc1)
    panicindex: panic(indexError)
    E:/dev/Go/src/code.gitea.io/gitea/modules/repofiles/tree.go:82 (0x123b1a5)
    GetTreeBySHA: tree.Entries[e].Path = entries[e].Name()
    E:/dev/Go/src/code.gitea.io/gitea/routers/api/v1/repo/tree.go:59 (0x143d95c)
    GetTree: if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.QueryInt("page"), ctx.QueryInt("per_page"), ctx.QueryBool("recursive")); err != nil {

Description

Issue with paging on /repos/{owner}/{repo}/git/trees/{sha} api, any page other than page 1 that should returns items throws an error 500

Reproduced with super simple repo with only 2 items:

works as expected:
http://localhost:3000/api/v1/repos/balbright2/awesomecode/git/trees/master?recursive=true&per_page=1&page=1

throws error 500:
http://localhost:3000/api/v1/repos/balbright2/awesomecode/git/trees/master?recursive=true&per_page=1&page=2

Log snippet above
...

Originally created by @bhalbright on GitHub (Dec 21, 2019). - Gitea version (or commit ref): 4f42e03 - Git version: 2.19.1.windows.1 - Operating system: Windows 10 - Database (use `[x]`): - [ ] PostgreSQL - [ x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [ x] Not relevant - Log gist: 2019/12/20 22:25:14 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: index out of range E:/Go/src/runtime/panic.go:44 (0x42fbc1) panicindex: panic(indexError) E:/dev/Go/src/code.gitea.io/gitea/modules/repofiles/tree.go:82 (0x123b1a5) GetTreeBySHA: tree.Entries[e].Path = entries[e].Name() E:/dev/Go/src/code.gitea.io/gitea/routers/api/v1/repo/tree.go:59 (0x143d95c) GetTree: if tree, err := repofiles.GetTreeBySHA(ctx.Repo.Repository, sha, ctx.QueryInt("page"), ctx.QueryInt("per_page"), ctx.QueryBool("recursive")); err != nil { <rest ommitted> ## Description Issue with paging on /repos/{owner}/{repo}/git/trees/{sha} api, any page other than page 1 that should returns items throws an error 500 Reproduced with super simple repo with only 2 items: works as expected: http://localhost:3000/api/v1/repos/balbright2/awesomecode/git/trees/master?recursive=true&per_page=1&page=1 throws error 500: http://localhost:3000/api/v1/repos/balbright2/awesomecode/git/trees/master?recursive=true&per_page=1&page=2 Log snippet above ...
GiteaMirror added the type/bug label 2025-11-02 05:53:34 -06:00
Author
Owner

@bhalbright commented on GitHub (Dec 21, 2019):

I intend to submit a PR for this issue when I can fix it. This was actually found by an Unfolding Word developer https://github.com/unfoldingWord.

@bhalbright commented on GitHub (Dec 21, 2019): I intend to submit a PR for this issue when I can fix it. This was actually found by an Unfolding Word developer https://github.com/unfoldingWord.
Author
Owner

@lunny commented on GitHub (Dec 22, 2019):

Fixed by #9459

@lunny commented on GitHub (Dec 22, 2019): Fixed by #9459
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4529