New admin endpoints getAllOrgs and getAllUsers cause internal server error #2937

Closed
opened 2025-11-02 04:54:43 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @jgoldring on GitHub (Feb 19, 2019).

  • Gitea version (or commit ref): master (2982413f8d)
  • Git version: 2.20.1
  • Operating system: Arch Linux
  • Database (use [x]): (tested with both)
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io: (Don't have admin rights)
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist: http response
    gitea log

Description

The newly created admin endpoints getAllOrgs and getAllUsers return 500 errors right now. The returned error in the gist: PANIC:: runtime error: makeslice: cap out of range seems to be caused by a change made in commit: https://github.com/bmackinney/gitea/commit/df619cf35cab1173c329bc9099b62547cae21080

specifically in models/user.go, changing the <= to == when comparing the PageSize:

if opts.PageSize <= 0 || opts.PageSize > setting.UI.ExplorePagingNum {

to:

if opts.PageSize == 0 || opts.PageSize > setting.UI.ExplorePagingNum {

This change allows the value of -1 passed in by both calls to pass through to the call:

users = make([]*User, 0, opts.PageSize)

with PageSize still being set at -1, causing the "cap out of range" error.

Originally created by @jgoldring on GitHub (Feb 19, 2019). - Gitea version (or commit ref): master (2982413f8dc8d6976fb1f3839ee6abdd89da990b) - Git version: 2.20.1 - Operating system: Arch Linux - Database (use `[x]`): (tested with both) - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: (Don't have admin rights) - [ ] Yes (provide example URL) - [x] No - [ ] Not relevant - Log gist: [http response](https://gist.github.com/jgoldring/e03432562a0be69d742e09672f62fdb5.js) [gitea log](https://gist.github.com/jgoldring/5436dc551e10db4848d4d3cfbe128d49.js) ## Description The newly created admin endpoints getAllOrgs and getAllUsers return 500 errors right now. The returned error in the gist: `PANIC:: runtime error: makeslice: cap out of range` seems to be caused by a change made in commit: [https://github.com/bmackinney/gitea/commit/df619cf35cab1173c329bc9099b62547cae21080](url) specifically in models/user.go, changing the <= to == when comparing the PageSize: ```if opts.PageSize <= 0 || opts.PageSize > setting.UI.ExplorePagingNum {``` to: ```if opts.PageSize == 0 || opts.PageSize > setting.UI.ExplorePagingNum {``` This change allows the value of -1 passed in by both calls to pass through to the call: ```users = make([]*User, 0, opts.PageSize)``` with PageSize still being set at -1, causing the "cap out of range" error.
GiteaMirror added the type/bug label 2025-11-02 04:54:43 -06:00
Author
Owner

@jolheiser commented on GitHub (Feb 20, 2019):

The commit link above didn't get me anywhere, but for reference to whoever looks at this further, I think this is the commit that made the change: 1b90692844

@jolheiser commented on GitHub (Feb 20, 2019): The commit link above didn't get me anywhere, but for reference to whoever looks at this further, I think this is the commit that made the change: https://github.com/go-gitea/gitea/commit/1b90692844c1b714d9c03cf7c96e7f62923236c0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2937