Skip to content

Can't use API to PUT file the second time #8181

Closed

Description

@dvolozhinok

Gogs version

0.14.1

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 622aaf6099f5d9642a70f13b692c46e0fb2985de' \
  --header 'Content-Type: application/json' \
  --data '{
  "branch": "master",
  "message": "4",
  "content": "SGVsbG8K"
}'

It gives HTTP code 500 and the reply:

{
  "message": "Something went wrong, please check the server logs for more information.",
  "url": "https://github.com/gogs/docs-api"
}

In logs:

2026/02/16 14:30:35 [TRACE] Session ID: 49062c37948bd910
2026/02/16 14:30:35 [TRACE] CSRF Token: 622aaf6099f5d9642a70f13b692c46e0fb2985de
2026/02/16 14:30:35 [ERROR] [...al/route/api/v1/repo/contents.go:205 PutContents()] updating repository file: discard local repo branch[master] changes: reset [revision: origin/master]: exit status 128 - fatal: option '--end-of-options' must come before non-option arguments

If uptime of the service is low and the branch is new, not existing one it works and gives positive reply. And I can then open file through the web interface.
The second PUT request fails.
Any PUT request to master fails.

To reproduce

  1. Use the same distro;
  2. Add user for gogs + group;
  3. Add systemd service;
  4. Run it.

Expected behavior

Normally working API to PUT.

Additional context

Daemon file

[Unit]
Description=Gogs git remote daemon NEW
After=syslog.target
After=network.target

[Service]
LimitMEMLOCK=infinity
LimitNOFILE=131072
Type=simple
User=gogs_new
Group=gogs_new
WorkingDirectory=/opt/gogs_new
ExecStart=/opt/gogs_new/gogs web -p 4000
Restart=always
RestartSec=5s
Environment=USER=gogs_new HOME=/opt/gogs_new

[Install]
WantedBy=multi-user.target

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    💊 bug
    on Feb 16, 2026
  2. unknwon commented on Feb 18, 2026

    @unknwon
    Member

    Thanks for reporting! Looks like something is funky when shelling out to git. Gonna take a look.

  3. self-assigned this
    on Feb 18, 2026
  4. unknwon commented on Feb 19, 2026

    @unknwon
    Member

    Hey, all release artifacts of 0.14.2 were out yesterday!

  5. dvolozhinok commented on Feb 19, 2026

    @dvolozhinok
    Author

    Hey, all release artifacts of 0.14.2 were out yesterday!
    Thank you very much!
    It's working but I ran into another issue while using the API.
    Will report soon.

  6. unknwon commented on Feb 19, 2026

    @unknwon
    Member

    Oh no 😬 please tag me directly so I receive email notification for a faster response!

  7. locked as resolved and limited conversation to collaborators on May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

💊 bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions