Skip to content

Bug: Public API 500 error when creating file #8210

Closed as duplicate
Closed as duplicate

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

Activity

  1. added
    💊 bug
    on Mar 24, 2026
  2. Meldiron commented on Mar 24, 2026

    @Meldiron
    ContributorAuthor

    I have contributed a pull request to address this issue: #8211

    One test is failing, but not relevant to my changes - open to discussion. Also available to address any comments 🙌

  3. unknwon commented on Nov 12, 2026

    @unknwon
    Member

    This has the same cause as #8189 (PUT to an existing non-default branch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    💊 bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions