openshift-pipelines / pipelines-as-code

Pipelines-as-Code for Tekton
https://pipelinesascode.com
Apache License 2.0
124 stars 81 forks source link

Fix 404 error for GitLab provider #1692

Closed savitaashture closed 4 weeks ago

savitaashture commented 1 month ago

In GitLab, when there is an MR from a forked repo to a target repo, it gives a 404 error from the GetMergeRequestChanges function This PR addresses the fix

Signed-off-by: Savita Ashture sashture@redhat.com

Changes

Submitter Checklist

savitaashture commented 1 month ago

cc @gabemontero

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.

Project coverage is 64.58%. Comparing base (9dcbe19) to head (eaa4a2c). Report is 3 commits behind head on main.

Files Patch % Lines
pkg/customparams/standard.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1692 +/- ## ========================================== + Coverage 64.54% 64.58% +0.03% ========================================== Files 143 143 Lines 11098 11104 +6 ========================================== + Hits 7163 7171 +8 + Misses 3413 3412 -1 + Partials 522 521 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

chmouel commented 1 month ago

lgtm

what was decided @savitaashture about the lack of error processing at

https://github.com/openshift-pipelines/pipelines-as-code/blob/0e97e1d1afead542c99ce8004a9f800b0998efe8/pkg/provider/gitlab/gitlab.go#L213

because when you create a Merge Request (MR) from a fork in an upstream repository, the token needs to have write access to the fork repository to create a status. Typically, the token set on the Repository CR doesn't have such broad access, so we can't create a status commit on it.

I explained this poorly in a comment when I first implemented it a few years ago here:

https://github.com/openshift-pipelines/pipelines-as-code/blob/467aebb3d9fbba241cf4ad4001bd9db8ed7a64e9/pkg/provider/gitlab/gitlab.go#L189-L193

I asked our GitLab developer liaison about it but haven't received a response. I'm fairly certain there was a bug report in the GitLab instance addressing this issue. maybe something has changed since then ๐Ÿคท๐Ÿป

gabemontero commented 1 month ago

lgtm what was decided @savitaashture about the lack of error processing at https://github.com/openshift-pipelines/pipelines-as-code/blob/0e97e1d1afead542c99ce8004a9f800b0998efe8/pkg/provider/gitlab/gitlab.go#L213

because when you create a Merge Request (MR) from a fork in an upstream repository, the token needs to have write access to the fork repository to create a status. Typically, the token set on the Repository CR doesn't have such broad access, so we can't create a status commit on it.

I explained this poorly in a comment when I first implemented it a few years ago here:

https://github.com/openshift-pipelines/pipelines-as-code/blob/467aebb3d9fbba241cf4ad4001bd9db8ed7a64e9/pkg/provider/gitlab/gitlab.go#L189-L193

I asked our GitLab developer liaison about it but haven't received a response. I'm fairly certain there was a bug report in the GitLab instance addressing this issue. maybe something has changed since then ๐Ÿคท๐Ÿป

thanks for the detailed explanation @chmouel .... helps immensely

@savitaashture - in this PR let's get this info in a comment around https://github.com/openshift-pipelines/pipelines-as-code/blob/0e97e1d1afead542c99ce8004a9f800b0998efe8/pkg/provider/gitlab/gitlab.go#L213 so questions around this do not come up again in a few months and we have to re-research the "why"

savitaashture commented 4 weeks ago

Thank you @chmouel for explaining reason behind not handling the error

@chmouel @gabemontero I have updated the existing comment

PTAL Thank you

savitaashture commented 4 weeks ago

LGTM, was it tested manually as working ? (since there is no E2E)

Yes i did test manually

we need to have a fork repo to test this that's why did not add e2e