Skip to content

Error configuring marge-bot to merge only merge requests approved by custom approvers

In order to allow custom approvers (with 1 approval), I have configured approvers in variable $MAINTAINERS (git usernames) but this is failing with error This branch couldn't be merged: Insufficient approvals (have: ['my-username'] missing: 1)

The MR is approved by 'my-username' and then assigned to marge.The following configuration is used

marge-bot-template:
  image:
    name: marge-image-from-our-registry:0.15.3
    entrypoint: [""]
  stage: merge
  variables:
    MARGE_CLI: "true"
    MARGE_GITLAB_URL: "$CI_SERVER_URL"
    MARGE_AUTH_TOKEN: "$MARGE_AUTH_TOKEN"
    MARGE_BRANCH_REGEXP: "main"
    MARGE_USE_HTTPS: "true"
    MARGE_CI_TIMEOUT: "60min"
    MARGE_CUSTOM_APPROVER: $MAINTAINERS
    MARGE_CUSTOM_APPROVALS_REQUIRED: "1"
    MARGE_DEBUG: "true"
  script: marge.app
  rules:
   - if: '$CI_PIPELINE_SOURCE == "schedule"'
   - if: $CI_PIPELINE_SOURCE == "merge_request_event"
     when: manual

Debug logs :

2025-09-22 12:02:53,071 DEBUG REQUEST: POST https://gitlab-instance/api/v4/projects/2749051/merge_requests/4060/notes {'PRIVATE-TOKEN': '[MASKED]'} {'post_data': {'body': "This branch couldn't be merged: Insufficient approvals (have: ['username'] missing: 1)"}}
2025-09-22 12:02:53,258 DEBUG https://gitlab-instance:443 "POST /api/v4/projects/2749051/merge_requests/4060/notes HTTP/1.1" 201 
2025-09-22 12:02:53,259 DEBUG RESPONSE CODE: 201
2025-09-22 12:02:53,259 DEBUG RESPONSE BODY: b'{"id":45691094,"type":null,"body":"This branch couldn\'t be merged: Insufficient approvals (have: [\'username\'] missing: 1)","author":{"id":2094,"username":"marge","public_email":"marge@email.com","name":" Marge User","state":"active","locked":false,"avatar_url":"https://../avatar.png","web_url":".."},"created_at":"2025-09-22T14:02:53.154+02:00","updated_at":"2025-09-22T14:02:53.154+02:00","system":false,"noteable_id":5248321,"noteable_type":"MergeRequest","project_id":2749051,"resolvable":false,"confidential":false,"internal":false,"imported":false,"imported_from":"none","noteable_iid":4060,"commands_changes":{}}'

Any suggestions ?

Edited by Gowri LN