Skip to content

Bug: Public API 500 error when creating file #8210

@Meldiron

Description

@Meldiron

Gogs version

0.14.2

Git version

  • Server: 2.47.3
  • Client: 2.52.0

Operating system

MacOS 26.3.1 (25D2128)

Database

SQLite 3

Describe the bug

Creeate or update file endpoint /api/v1/repos/{owner}/{repo}/contents/{path} has edge-case which results in 500 server error.

To reproduce

  1. Create a repository
  2. Create master branch with README.md
  3. Create branch feature from master branch content
  4. Use endpoint /api/v1/repos/{owner}/{repo}/contents/{path} to upload TEST.md to feature branch

Actual behaviour:

500 server error

2026/03/23 20:23:53 [ERROR] [...al/route/api/v1/repo/contents.go:209 PutContents()] updating repository file: branch already exists [name: feature]

Expected behavior

Create file, 2xx response, no issue.

Additional context

No response

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    💊 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions