Repository navigation
Closed
Labels
💊 bugSomething isn't working
Description
Gogs version
0.14.2
Git version
- Server: 2.39.3
- Client: N\A (I believe 2.39.3 since I'm using the API)
Operating system
Oracle Linux Server 8.8
Database
sqlite3
Describe the bug
Using HTTPie GUI to make this request:
curl --request PUT \
--url https://git.our.org:4443/api/v1/repos/obsidian/users/contents/hello.csv \
--header 'Authorization: token 56ec7793e90ce8d94371f8d1d5cfd8fc1d5a0256' \
--header 'Content-Type: application/json' \
--data '{
"branch": "branch1",
"message": "9",
"content": "0JfQtNGA0LDRgdGC0LXQlDEyMzUK"
}'And it gives 201 and works normally.
Then let's PUT again:
curl --request PUT \
--url https://git.our.org:4443/api/v1/repos/obsidian/users/contents/hello.csv \
--header 'Authorization: token 56ec7793e90ce8d94371f8d1d5cfd8fc1d5a0256' \
--header 'Content-Type: application/json' \
--data '{
"branch": "branch1",
"message": "9",
"content": "0JfQtNGA0LDRgdGC0LXQlDEyMzUK"
}'It gives code 500 and answer:
{
"message": "Something went wrong, please check the server logs for more information.",
"url": "https://github.com/gogs/docs-api"
}
In logs we have nothing interesting:
2026/02/20 15:00:06 [TRACE] Session ID: 13eb88e882ac620d
2026/02/20 15:00:06 [TRACE] CSRF Token: x443K6qqqC1G3w6PBs5Sc5C5rMQ6MTc3MTU4ODgwNjc4NjY1NTM0Nw
2026/02/20 15:00:06 [ERROR] [...al/route/api/v1/repo/contents.go:205 PutContents()] updating repository file: branch already exists [name: dcloud]
2026/02/20 15:02:25 [TRACE] Session ID: ed15c07425b2c453
2026/02/20 15:02:25 [TRACE] CSRF Token: 7xwlLTqkyt9VPk9sZAokPjItz8o6MTc3MTU4ODk0NTkzODU4MjE2NA
2026/02/20 15:02:26 [TRACE] TriggerTask: obsidian/users@branch1 by "dcloud.ru"
2026/02/20 15:02:26 [TRACE] DeliverHooks [repo_id: 1]
2026/02/20 15:02:26 [TRACE] AddTestPullRequestTask [head_repo_id: 1, head_branch: branch1]: finding pull requests
2026/02/20 15:02:26 [TRACE] AddTestPullRequestTask [base_repo_id: 1, base_branch: branch1]: finding pull requests
2026/02/20 15:03:27 [TRACE] Session ID: 86dff5b578371c94
2026/02/20 15:03:27 [TRACE] CSRF Token: PPVFgc0WP1meDKMCV9LigpAwpaw6MTc3MTU4OTAwNzU0OTY1NDE3OQ
2026/02/20 15:03:27 [ERROR] [...al/route/api/v1/repo/contents.go:205 PutContents()] updating repository file: branch already exists [name: branch1]
To reproduce
- Use the same distro;
- Add user and group for gogs;
- Add systemd service;
- Run it;
- Add 2 users;
- Create repo from 1st user;
- Add permissions to write for the 2nd user;
- Add marker API key for non-author of the repo for the 2nd user;
- Perform the same requests.
Expected behavior
Second PUT without errors and with code 201.
Additional context
@unknwon Good day, I've tagged you as we previously agreed in issue #8181
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
💊 bugSomething isn't working
Activity
[-]Can't post to non-master branch via API[/-][+]Can't PUT again to non-master branch via API[/+]unknwon commentedon Feb 20, 2026
Hey @dvolozhinok, thanks for the report! Just quick check, it was wrong before 0.14 for you? (if you don't know it's OK just wanna collect a data point).
dvolozhinok commentedon Feb 20, 2026
I don't know. I've started using this API from version 0.14.1
I've launched another Gogs instance with separate user and sqlite3 as DB for the separate project which is in dev right now.
For existing project we use not the latest Gogs, SSH-based pushes only and never update it. We follow the electricians' principle "It works — don't touch it!"
unknwon commentedon Feb 20, 2026
Haha, makes the perfect sense!