Skip to content

allow_manual_merge requires explicit has_pull_requests: true in Gitea API PATCH repos/{owner}/{repo} #37336

@andrii-suse

Description

@andrii-suse

Description

When updating repository settings via the Gitea API (PATCH /api/v1/repos/{owner}/{repo}), attempting to enable allow_manual_merge silently fails (returns 200 OK but changes nothing) unless has_pull_requests: true is explicitly included in the same request body.

Note that has_pull_requests was already set, so should not be required.

Reproduction Steps

  1. Create a fresh repository
    New repositories have has_pull_requests: true and allow_manual_merge: false by default.
   curl -X POST -H "Authorization: token <TOKEN>" -H "Content-Type: application/json" \
     -d '{"name": "repro-repo", "auto_init": true}' \
     http://localhost:3000/api/v1/user/repos
  1. Verify Initial State
   curl -s -H "Authorization: token <TOKEN>" \
     http://localhost:3000/api/v1/repos/admin/repro-repo | \
     jq '.has_pull_requests, .allow_manual_merge'
  Output:
   true
   false
  1. Attempt to enable allow_manual_merge independently
    Note that we are only sending the field we wish to change.
   curl -s -X PATCH -H "Authorization: token <TOKEN>" -H "Content-Type: application/json" \
     -d '{"allow_manual_merge": true}' \
     http://localhost:3000/api/v1/repos/admin/repro-repo | \
     jq '.has_pull_requests, .allow_manual_merge'
  Output:
   true
   false

(Observation: The API returns 200 OK and the repo object, but allow_manual_merge remains false.)

  1. Verify state with a GET request
   curl -s -H "Authorization: token <TOKEN>" \
     http://localhost:3000/api/v1/repos/admin/repro-repo | \
     jq '.has_pull_requests, .allow_manual_merge'
  Output:
   true
   false

(Observation: The setting did not persist.)

  1. Attempt to enable both has_pull_requests and allow_manual_merge
   curl -s -X PATCH -H "Authorization: token <TOKEN>" -H "Content-Type: application/json" \
     -d '{"has_pull_requests": true, "allow_manual_merge": true}' \
     http://localhost:3000/api/v1/repos/admin/repro-repo | \
     jq '.has_pull_requests, .allow_manual_merge'
  Output:
   true
   true

(Observation: The setting is now successfully updated to true.)


Expected Behavior
The API should update the allow_manual_merge field if it is provided in the payload, especially if the prerequisite (has_pull_requests) is already met on the server side. If Gitea requires certain fields to be "bundled" for validation, it should return an error (e.g., 422 Unprocessable Entity) instead of silently ignoring the field and returning 200 OK.

Observed Behavior
The allow_manual_merge field is ignored unless has_pull_requests: true is present in the same PATCH payload, regardless of the repository's current state.

Gitea Version

1.25.5

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Test Container

Database

MySQL/MariaDB

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/needs-feedbackFor bugs, we need more details. For features, the feature must be described in more detailtype/bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions