woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.07k stars 351 forks source link

Enabling repository results in: pq: duplicate key value violates unique constraint "UQE_orgs_name" #2922

Open simmstein opened 9 months ago

simmstein commented 9 months ago

Component

server

Describe the bug

Hello,

Encountered an issue when attempting to add a new repository from a GitLab instance hosted on-premise. The error message received is as follows: pq: duplicate key value violates unique constraint "UQE_orgs_name". It works once time but I was the only one developer linked to this organization. Now we are more.

Context: The GitLab setup involves multiple organizations, and the bug manifests when trying to add a repository of the second organization.

Should be linked to #2092

We are owners of the organization.

System Info

Version: next-adb2c82790
Forge: Gitlab (on premise)
Deployment: docker swarm

Additional context

Good Not good
fine not_fine

Server log:

***redacted***_woodpeckerci_woodpecker-server.1.y8k5453nahp3@***redacted***    | {"level":"debug","ip":"***redacted***","latency":594.416323,"method":"POST","path":"/api/repos","status":500,"time":"2023-12-08T08:57:53Z","user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0","time":"2023-12-08T08:57:53Z","caller":"/woodpecker/src/github.com/woodpecker-ci/woodpecker/server/router/middleware/logger.go:59"}

Validations

qwerty287 commented 9 months ago

Can you check the content of your DB? What's the data in the orgs.org_name column?

simmstein commented 9 months ago

It's sysadmin/sub-group. By renaming to sysadmin, it seems to work back but it's strange.

anbraten commented 9 months ago

That sounds link an issue with sub-groups. I will try to give it a look

simmstein commented 8 months ago

I don't if another commit fix this error but after upgrading to the latest version, It seems to work now.

Lindenk commented 2 months ago

I'm currently having this issue (I'm on the latest in the nixpkgs, v2.5.0). I also noticed that:

Lindenk commented 2 months ago

Update: It appears that manually changing the database row does solve the issue. After modifying the row and adding the second repo, it appears the new repo is using the correct org as well