API: Empty list for organization members that should not be empty #6316

Closed
opened 2025-11-02 06:52:22 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @joepie91 on GitHub (Nov 15, 2020).

Additional information: This Gitea instance was migrated recently from a very old Gogs installation, in the two-step process described in the Gitea documentation. The organization/user in this issue date from before that migration.

Description

I'm currently building a spam removal tool for my Gitea instance that uses the API. However, in at least one case, the API returns an incorrect response.

When querying https://git.cryto.net/api/v1/users/SharrySteve1/orgs, the following output is produced:

[
  {
    id: 5617,
    username: 'CIPD-assignment-help',
    full_name: 'CIPD-assignment-help',
    avatar_url: 'https://git.cryto.net/user/avatar/CIPD-assignment-help/-1',
    description: '',
    website: '',
    location: '',
    visibility: 'public',
    repo_admin_change_team_access: false
  },
  {
    id: 5618,
    username: 'HND',
    full_name: 'HND',
    avatar_url: 'https://git.cryto.net/user/avatar/HND/-1',
    description: '',
    website: '',
    location: '',
    visibility: 'public',
    repo_admin_change_team_access: false
  },
  {
    id: 5615,
    username: 'NursingWritingArsenal',
    full_name: 'NursingWritingArsenal',
    avatar_url: 'https://git.cryto.net/user/avatar/NursingWritingArsenal/-1',
    description: '',
    website: '',
    location: '',
    visibility: 'public',
    repo_admin_change_team_access: false
  }
]

... and when querying https://git.cryto.net/api/v1/orgs/NursingWritingArsenal/members this is the result:

[]

... but this should contain the earlier-queried SharrySteve1 user. This occurs even when querying using an admin token.

On the actual pages for this user and organization, the membership is displayed correctly:

For other organizations, the output also seems to be correct.

The logs (loglevel debug) do not seem to include anything relevant. How can I debug this further?

Screenshots

N/A

Originally created by @joepie91 on GitHub (Nov 15, 2020). - Gitea version (or commit ref): 1.11.8 - Git version: 2.25.4 - Operating system: NixOS 20.03 - installed from distro package <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [x] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - Log gist: https://gist.github.com/joepie91/57626c69d090d83bccf57d3ce401b82b <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> __Additional information:__ This Gitea instance was migrated recently from a very old Gogs installation, in the two-step process described in the Gitea documentation. The organization/user in this issue date from before that migration. ## Description I'm currently building a spam removal tool for my Gitea instance that uses the API. However, in at least one case, the API returns an incorrect response. When querying https://git.cryto.net/api/v1/users/SharrySteve1/orgs, the following output is produced: ```js [ { id: 5617, username: 'CIPD-assignment-help', full_name: 'CIPD-assignment-help', avatar_url: 'https://git.cryto.net/user/avatar/CIPD-assignment-help/-1', description: '', website: '', location: '', visibility: 'public', repo_admin_change_team_access: false }, { id: 5618, username: 'HND', full_name: 'HND', avatar_url: 'https://git.cryto.net/user/avatar/HND/-1', description: '', website: '', location: '', visibility: 'public', repo_admin_change_team_access: false }, { id: 5615, username: 'NursingWritingArsenal', full_name: 'NursingWritingArsenal', avatar_url: 'https://git.cryto.net/user/avatar/NursingWritingArsenal/-1', description: '', website: '', location: '', visibility: 'public', repo_admin_change_team_access: false } ] ``` ... and when querying https://git.cryto.net/api/v1/orgs/NursingWritingArsenal/members this is the result: ```js [] ``` ... but this *should* contain the earlier-queried `SharrySteve1` user. This occurs even when querying using an admin token. On the actual pages for this user and organization, the membership is displayed correctly: - https://git.cryto.net/SharrySteve1 - https://git.cryto.net/HND For other organizations, the output also seems to be correct. The logs (loglevel debug) do not seem to include anything relevant. How can I debug this further? ## Screenshots N/A
Author
Owner

@techknowlogick commented on GitHub (Nov 15, 2020):

Please upgrade to at least the latest stable version. There are hundreds of commits between the version you are on and the latest stable and the behaviour may have changed.

@techknowlogick commented on GitHub (Nov 15, 2020): Please upgrade to at least the latest stable version. There are hundreds of commits between the version you are on and the latest stable and the behaviour may have changed.
Author
Owner

@joepie91 commented on GitHub (Nov 15, 2020):

I've upgraded to 1.12.5, and while it does show the members now, it still seems wrong:

[{
	"id": 5614,
	"login": "SharrySteve1",
	"full_name": "",
	"email": "xxxx@gmail.com",
	"avatar_url": "https://git.cryto.net/user/avatar/SharrySteve1/-1",
	"language": "",
	"is_admin": false,
	"last_login": "1970-01-01T01:00:00+01:00",
	"created": "2020-11-07T10:36:35+01:00",
	"username": "SharrySteve1"
}]

Shouldn't it be impossible for an organization to have zero admins?

@joepie91 commented on GitHub (Nov 15, 2020): I've upgraded to `1.12.5`, and while it *does* show the members now, it still seems wrong: ```json [{ "id": 5614, "login": "SharrySteve1", "full_name": "", "email": "xxxx@gmail.com", "avatar_url": "https://git.cryto.net/user/avatar/SharrySteve1/-1", "language": "", "is_admin": false, "last_login": "1970-01-01T01:00:00+01:00", "created": "2020-11-07T10:36:35+01:00", "username": "SharrySteve1" }] ``` Shouldn't it be impossible for an organization to have zero admins?
Author
Owner

@techknowlogick commented on GitHub (Nov 16, 2020):

is_admin is not referring to the user's standing in the org, but rather on the instance itself.

As upgrading resolved this issue I will close this ticket.

@techknowlogick commented on GitHub (Nov 16, 2020): `is_admin` is not referring to the user's standing in the org, but rather on the instance itself. As upgrading resolved this issue I will close this ticket.
Author
Owner

@joepie91 commented on GitHub (Nov 16, 2020):

Ah, this was not clear from the API documentation. In that case, how do I determine the standing (specifically admin/owner status) within the organization?

@joepie91 commented on GitHub (Nov 16, 2020): Ah, this was not clear from the API documentation. In that case, how *do* I determine the standing (specifically admin/owner status) within the organization?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6316