Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branch protection duplicate key #23998

Closed
devops-digitalsilk opened this issue Apr 8, 2023 · 0 comments · Fixed by #24013
Closed

Branch protection duplicate key #23998

devops-digitalsilk opened this issue Apr 8, 2023 · 0 comments · Fixed by #24013
Labels
Milestone

Comments

@devops-digitalsilk
Copy link

devops-digitalsilk commented Apr 8, 2023

Description

After upgrading gitea to version 1.19.0 the my script via API can't protect branches anymore.

  1. Tried creating the branch protection manually via user interface - worked
  2. Creating branch protection via swagger worked too
  3. Creating branch protection via API - doesn't work

Simply run the bash script to put protection on master:

curl -X 'POST' \ "https://gitea.com/api/v1/repos/projects/project/branch_protections?token=KEY" \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "branch_name": "master" }'

Gitea Version

1.19

Can you reproduce the bug on the Gitea demo site?

No, can't find token key

Log Gist

2023/04/06 09:30:56 [642e9150-3] router: completed DELETE /api/v1/repos/projects/demo/branch_protections/master for ip:0, 404 Not Found in 24.8ms @ repo/branch.go:856(repo.DeleteBranchProtection) 2023/04/06 09:30:57 [642e9151-2] router: completed DELETE /api/v1/repos/projects/demo/branch_protections/develop for ip:0, 404 Not Found in 25.9ms @ repo/branch.go:856(repo.DeleteBranchProtection) 2023/04/06 09:30:57 [642e9151-4] router: completed POST /api/v1/repos/projects/demo/branch_protections for ip:0, 201 Created in 134.2ms @ repo/branch.go:384(repo.CreateBranchProtection) 2023/04/06 09:30:58 ...pi/v1/repo/branch.go:532:CreateBranchProtection() [E] [642e9152] UpdateProtectBranch: Insert: pq: duplicate key value violates unique constraint "UQE_protected_branch_s" 2023/04/06 09:30:58 [642e9152] router: completed POST /api/v1/repos/projects/demo/branch_protections for ip:0, 500 Internal Server Error in 46.2ms @ repo/branch.go:384(repo.CreateBranchProtection)

Screenshots

image

Git Version

git version 2.38.4

Operating System

Linux 3e9cf1c58088 5.4.0-122-generic #138-Ubuntu

How are you running Gitea?

Docker image

Database

PostgreSQL

@lunny lunny added this to the 1.19.1 milestone Apr 9, 2023
techknowlogick pushed a commit that referenced this issue Apr 10, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Apr 10, 2023
lunny added a commit that referenced this issue Apr 10, 2023
Backport #24013 by @lunny

Fix #23998

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants