Skip to content

Conversation

@olblak
Copy link
Member

@olblak olblak commented Nov 21, 2025

Fix #6083

Test

/

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

Potential improvement

@chrxmvtik
Copy link
Contributor

chrxmvtik commented Nov 21, 2025

From my experience with GitLab API, there will be required some sort of handling before running AcceptMergeRequest.

There might occur some race condition, when you create a merge request, and it's pipeline is not scheduled yet - running AcceptMergeRequest immediately will just throw some random errors from API.

EDIT: Maybe some polling with a small timeout watching for a head pipeline?

@chrxmvtik
Copy link
Contributor

Created a pull request with possible solution at this PR.

@olblak
Copy link
Member Author

olblak commented Nov 22, 2025

Thanks for the PR and for testing.
You are right.
I found a very simple Gitlab repository that I can use for testing and testing this PR returns

Target branch:	"master"
ERROR: action stage:	"set auto-merge on GitLab mergerequest: PUT https://gitlab.com/api/v4/projects/olblak%2Fdocker-examples/merge_requests/1/merge: 401 {message: 401 Unauthorized}"

Your code is probably in the right direction, I'll test it later today

@olblak
Copy link
Member Author

olblak commented Nov 22, 2025

After additional tests, it appears that I needed an access token with at least the maintainer permission and scope set to API

I think the retry you are mentioning is already handled by this https://github.com/olblak/updatecli/blob/eac7e4b42a6aa3ab21e96c96a9c2ef1b5c3d8f85/pkg/plugins/resources/gitlab/mergerequest/create.go#L101

Which is the code snippet heavily inspired from https://pkg.go.dev/gitlab.com/gitlab-org/api/client-go#example-WithRequestRetry-CreateMergeRequestAndSetAutoMerge

@chrxmvtik
Copy link
Contributor

Yup, this might be sufficient, needs testing simulating "slow" environment

@olblak olblak enabled auto-merge (squash) November 23, 2025 11:12
@olblak
Copy link
Member Author

olblak commented Nov 23, 2025

I am going to merge this PR. We can always improve in the future

@olblak olblak merged commit ac2278a into updatecli:main Nov 23, 2025
5 checks passed
@olblak olblak added the enhancement New feature or request label Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-gitlab enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support GitLab Merge Request Auto-Merge Option

2 participants