Users in owner team get 404 when accessing organisation repos #2293

Closed
opened 2025-11-02 04:31:31 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @cybrwshl on GitHub (Sep 4, 2018).

  • Gitea version (or commit ref): 38d8b8c
  • Git version: 2.15.2
  • Operating system: Alpine (gitea/gitea:1.5.1)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

Users that are in the owner team of a organisation get a 404 error if they try to access a repository of their organisaton. The gitea log shows the following messages:

... [...routers/repo/view.go:299 Home()] [E] Home: Du hast keine Berechtigung, um auf irgendeinen Bereich dieses Repositories zuzugreifen.

The users are only in this team and organisation. All broken repos belong to the same organisation. With a administrator user it is possible to use this repos without any problems.

EDIT:
Maybe this problem is related to https://github.com/go-gitea/gitea/issues/2686 .

EDIT2:
content of table repo_unit:

+-----+---------+------+--------------------------------------------------------------------+--------------+
| id  | repo_id | type | config                                                             | created_unix |
+-----+---------+------+--------------------------------------------------------------------+--------------+
| 267 |      43 |    1 | NULL                                                               |   1535012857 |
| 268 |      43 |    2 | {"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true} |   1535012857 |
| 269 |      43 |    3 | NULL                                                               |   1535012857 |
| 270 |      43 |    4 | NULL                                                               |   1535012857 |
| 271 |      43 |    5 | NULL                                                               |   1535012857 |
+-----+---------+------+--------------------------------------------------------------------+--------------+
Originally created by @cybrwshl on GitHub (Sep 4, 2018). - Gitea version (or commit ref): 38d8b8c - Git version: 2.15.2 - Operating system: Alpine (gitea/gitea:1.5.1) - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - [ ] Not relevant ## Description Users that are in the owner team of a organisation get a 404 error if they try to access a repository of their organisaton. The gitea log shows the following messages: ```log ... [...routers/repo/view.go:299 Home()] [E] Home: Du hast keine Berechtigung, um auf irgendeinen Bereich dieses Repositories zuzugreifen. ``` The users are only in this team and organisation. All broken repos belong to the same organisation. With a administrator user it is possible to use this repos without any problems. EDIT: Maybe this problem is related to https://github.com/go-gitea/gitea/issues/2686 . EDIT2: content of table `repo_unit`: ``` +-----+---------+------+--------------------------------------------------------------------+--------------+ | id | repo_id | type | config | created_unix | +-----+---------+------+--------------------------------------------------------------------+--------------+ | 267 | 43 | 1 | NULL | 1535012857 | | 268 | 43 | 2 | {"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true} | 1535012857 | | 269 | 43 | 3 | NULL | 1535012857 | | 270 | 43 | 4 | NULL | 1535012857 | | 271 | 43 | 5 | NULL | 1535012857 | +-----+---------+------+--------------------------------------------------------------------+--------------+ ```
Author
Owner

@OndrejSpanel commented on GitHub (Sep 6, 2018):

I can see the same issue with a freshly installed Gitea version 1.5.1

The users can access other users private repositories when assigned as colaborators, but I cannot assign them as collaborators to an organization repository, when I attempt to do that I get error "The user is an organization member who cannot be added as a collaborator."

The error in the log is:

2018/09/06 11:24:01 [...routers/repo/http.go:217 HTTP()] [E] User XXXXX does not have allowed access to repository /home/gitea/gitea-repositories/nnnnn/nnnnn_private.git 's code

@OndrejSpanel commented on GitHub (Sep 6, 2018): I can see the same issue with a freshly installed Gitea version 1.5.1 The users can access other users private repositories when assigned as colaborators, but I cannot assign them as collaborators to an organization repository, when I attempt to do that I get error "The user is an organization member who cannot be added as a collaborator." The error in the log is: > 2018/09/06 11:24:01 [...routers/repo/http.go:217 HTTP()] [E] User XXXXX does not have allowed access to repository /home/gitea/gitea-repositories/nnnnn/nnnnn_private.git 's code
Author
Owner

@lunny commented on GitHub (Sep 7, 2018):

@OndrejSpanel #4814 will resolve your problem. But your problem is different from this one.

@lunny commented on GitHub (Sep 7, 2018): @OndrejSpanel #4814 will resolve your problem. But your problem is different from this one.
Author
Owner

@cybrwshl commented on GitHub (Sep 17, 2018):

Are there any further information that I should provide you? Or something I could check?

@cybrwshl commented on GitHub (Sep 17, 2018): Are there any further information that I should provide you? Or something I could check?
Author
Owner

@cybrwshl commented on GitHub (Sep 17, 2018):

I solved the problem by myself. The table team_unit was completly empty, so inserted the needed entries for all owner teams.

@cybrwshl commented on GitHub (Sep 17, 2018): I solved the problem by myself. The table `team_unit` was completly empty, so inserted the needed entries for all owner teams.
Author
Owner

@nuno-silva commented on GitHub (Oct 13, 2018):

I have upgraded from gitea 1.4.3 to 1.5.2 and am experiencing this problem. My team_unit table is empty.
@lunny has this been fixed in any version/commit prior to 1.5.2? Should I do as @cybrwshl and insert the entries manually? 😢

@nuno-silva commented on GitHub (Oct 13, 2018): I have upgraded from gitea 1.4.3 to 1.5.2 and am experiencing this problem. My `team_unit` table is empty. @lunny has this been fixed in any version/commit prior to 1.5.2? Should I do as @cybrwshl and insert the entries manually? :cry:
Author
Owner

@lafriks commented on GitHub (Oct 14, 2018):

@nuno-silva I believe so :(

@lafriks commented on GitHub (Oct 14, 2018): @nuno-silva I believe so :(
Author
Owner

@lunny commented on GitHub (Oct 15, 2018):

@nuno-silva as @lafriks said.

@lunny commented on GitHub (Oct 15, 2018): @nuno-silva as @lafriks said.
Author
Owner

@nuno-silva commented on GitHub (Feb 5, 2019):

So I've tracked this down to commit 0b3ea42847 (as part of #4034).
It seems like the team_unit table was added in this commit (or 1.5.0) and seems to have replaced the team.unit_types column.
The "move team units to team_unit table" migration should have populated the team_unit when I upgraded (in my case, from 1.4.3 to 1.5.2), right?

0b3ea42847/models/migrations/migrations.go (L193-L194)

I've just done a new migration (on another instance) from gitea 1.4.1 to 1.5.2 and it worked 😆 😕 . I fixed the other instance manually :/

For future reference, if you have this issue, what needs to be done is to turn each of the numbers in unit_types (for each row) from

select id as team_id,org_id,unit_types from team where unit_types is not NULL and unit_types like '%[%]%';

into an entry in the team_unit table.

For example:

MariaDB [gitea]> select id as team_id,org_id,unit_types from team where unit_types is not NULL and unit_types like '%[%]%';
+---------+--------+-----------------+
| team_id | org_id | unit_types      |
+---------+--------+-----------------+
|  1      |      3 | [1,2,3,4,5,6,7] |
+---------+--------+-----------------+
1 row in set (0.02 sec)

would be

MariaDB [gitea]> select * from team_unit;
+----+--------+---------+------+
| id | org_id | team_id | type |
+----+--------+---------+------+
|  1 |      3 |       1 |    1 |
|  2 |      3 |       1 |    2 |
|  3 |      3 |       1 |    3 |
|  4 |      3 |       1 |    4 |
|  5 |      3 |       1 |    5 |
|  6 |      3 |       1 |    6 |
|  7 |      3 |       1 |    7 |
+----+--------+---------+------+
7 rows in set (0.00 sec)
@nuno-silva commented on GitHub (Feb 5, 2019): So I've tracked this down to commit 0b3ea42847 (as part of #4034). It seems like the `team_unit` table was added in this commit (or `1.5.0`) and seems to have replaced the `team.unit_types` column. The `"move team units to team_unit table"` migration should have populated the `team_unit` when I upgraded (in my case, from `1.4.3` to `1.5.2`), right? https://github.com/go-gitea/gitea/blob/0b3ea428477b9da33f40252e79aafe85b09526f3/models/migrations/migrations.go#L193-L194 I've just done a new migration (**on another instance**) from gitea `1.4.1` to `1.5.2` and it worked :laughing: :confused: . I fixed the other instance manually :/ For future reference, if you have this issue, what needs to be done is to turn each of the numbers in `unit_types` (for each row) from ```sql select id as team_id,org_id,unit_types from team where unit_types is not NULL and unit_types like '%[%]%'; ``` into an entry in the `team_unit` table. For example: ```sql MariaDB [gitea]> select id as team_id,org_id,unit_types from team where unit_types is not NULL and unit_types like '%[%]%'; +---------+--------+-----------------+ | team_id | org_id | unit_types | +---------+--------+-----------------+ | 1 | 3 | [1,2,3,4,5,6,7] | +---------+--------+-----------------+ 1 row in set (0.02 sec) ``` would be ```sql MariaDB [gitea]> select * from team_unit; +----+--------+---------+------+ | id | org_id | team_id | type | +----+--------+---------+------+ | 1 | 3 | 1 | 1 | | 2 | 3 | 1 | 2 | | 3 | 3 | 1 | 3 | | 4 | 3 | 1 | 4 | | 5 | 3 | 1 | 5 | | 6 | 3 | 1 | 6 | | 7 | 3 | 1 | 7 | +----+--------+---------+------+ 7 rows in set (0.00 sec) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2293