Fix gitea access lists staying up to date #289

Open
opened 2026-01-17 10:53:26 +01:00 by oysteikt · 4 comments
Owner

Apparently gitea access to repositories are either cached or just inherently stateful? Because despite @vegardbm being in the Owners team, he does not exist in the access table, and we're unable to assign him to anything here.

Running this against the gitea database on postgres only yields 23 out of the currently 25 users in Drift Owners, vegard is one of the two missing:

SELECT
  "repository"."name",
  "user"."name",
  "access"."mode"
FROM "access"
JOIN "user" ON "user"."id" = "access"."user_id"
JOIN "repository" ON "repository"."id" = "access"."repo_id"
WHERE "repository"."name" = 'issues';

Maybe there's a way to regenerate the access table from within the admin panel? Otherwise, I also think we should consider filing it upstream as a bug report

Apparently gitea access to repositories are either cached or just inherently stateful? Because despite @vegardbm being in the `Owners` team, he does not exist in the access table, and we're unable to assign him to anything here. Running this against the gitea database on postgres only yields 23 out of the currently 25 users in `Drift` `Owners`, vegard is one of the two missing: ```SQL SELECT "repository"."name", "user"."name", "access"."mode" FROM "access" JOIN "user" ON "user"."id" = "access"."user_id" JOIN "repository" ON "repository"."id" = "access"."repo_id" WHERE "repository"."name" = 'issues'; ``` Maybe there's a way to regenerate the access table from within the admin panel? Otherwise, I also think we should consider filing it upstream as a bug report
oysteikt added the buggitea labels 2026-01-17 10:53:26 +01:00
oysteikt added this to the Kanban project 2026-01-17 10:53:26 +01:00
Author
Owner

I could not find any such regeneration action on neither https://git.pvv.ntnu.no/-/admin nor https://git.pvv.ntnu.no/-/admin/monitor/cron

I could not find any such regeneration action on neither https://git.pvv.ntnu.no/-/admin nor https://git.pvv.ntnu.no/-/admin/monitor/cron
Author
Owner

Temporary fix:

gitea=# BEGIN TRANSACTION;
BEGIN

gitea=*# INSERT INTO "access" ("user_id", "repo_id", "mode")
SELECT
  "team_user"."uid",
  "team_repo"."repo_id",
  MAX("team"."authorize")
FROM "team_user"
JOIN "team" ON "team"."id" = "team_user"."team_id"
JOIN "team_repo" ON "team_repo"."team_id" = "team"."id"
GROUP BY
  "team_user"."uid",
  "team_repo"."repo_id"
ON CONFLICT ("user_id", "repo_id") DO NOTHING;
INSERT 0 754

gitea=*#  SELECT
  "repository"."name",
  "user"."name",
  "access"."mode"
FROM "access"
JOIN "user" ON "user"."id" = "access"."user_id"
JOIN "repository" ON "repository"."id" = "access"."repo_id"
WHERE "repository"."name" = 'issues';
  name  |    name    | mode
--------+------------+------
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4
 issues | <censored> |    4

(25 rows)

gitea=*# COMMIT;

Apparently there were 700 something missing rows? what

Temporary fix: ```sql gitea=# BEGIN TRANSACTION; BEGIN gitea=*# INSERT INTO "access" ("user_id", "repo_id", "mode") SELECT "team_user"."uid", "team_repo"."repo_id", MAX("team"."authorize") FROM "team_user" JOIN "team" ON "team"."id" = "team_user"."team_id" JOIN "team_repo" ON "team_repo"."team_id" = "team"."id" GROUP BY "team_user"."uid", "team_repo"."repo_id" ON CONFLICT ("user_id", "repo_id") DO NOTHING; INSERT 0 754 gitea=*# SELECT "repository"."name", "user"."name", "access"."mode" FROM "access" JOIN "user" ON "user"."id" = "access"."user_id" JOIN "repository" ON "repository"."id" = "access"."repo_id" WHERE "repository"."name" = 'issues'; name | name | mode --------+------------+------ issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 issues | <censored> | 4 (25 rows) gitea=*# COMMIT; ``` Apparently there were 700 something missing rows? what
oysteikt changed title from Fix @vegardbm's access to the gitea issues to Fix gitea access lists staying up to date 2026-01-17 11:12:14 +01:00
oysteikt reopened this issue 2026-01-17 11:12:18 +01:00
Author
Owner

We should fix this permanently somehow... Feels kinda hacky to do this one over and over

We should fix this permanently somehow... Feels kinda hacky to do this one over and over
oysteikt moved this to Medium priority in Kanban on 2026-01-17 11:22:56 +01:00
Author
Owner

Can't seem to find any correlated issue on the gitea issue tracker

Can't seem to find any correlated issue on the gitea issue tracker
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Drift/issues#289