Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment lgtm in gitlab but always returns "you cannot LGTM your own PR." #1154

Closed
soulseen opened this issue Nov 10, 2020 · 15 comments
Closed

Comments

@soulseen
Copy link
Contributor

soulseen commented Nov 10, 2020

when I installed lighthouse witn provider gitlab, and it running well. But I comment lgtm in Merge Requests, it always returns

you cannot LGTM your own PR.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository.


No matter what user created MR, or what user commented on LGTM, the bot always returns it above.

what's more

I found the cause is Comment author same with MergeReuests author. ref https://github.com/jenkins-x/lighthouse/blob/master/pkg/plugins/lgtm/lgtm.go#L267

and the root cause is in jenkins-x/go-scm, the func convertMergeRequestCommentHook is used the same user to struct PullRequest and Comment

My team has used the lighthouse in a deep way, what are the roadmap of the lighthouse and the next step improvement? and I can provide some help.

@soulseen soulseen changed the title can not comment lgtm in gitlab provider comment lgtm in gitlab but always "you cannot LGTM your own PR." Nov 10, 2020
@soulseen soulseen changed the title comment lgtm in gitlab but always "you cannot LGTM your own PR." comment lgtm in gitlab but always returns "you cannot LGTM your own PR." Nov 10, 2020
@slimm609
Copy link
Contributor

I am seeing this same issue on gitlab.

@slimm609
Copy link
Contributor

according to https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#comment-on-merge-request

it looks like using object_attributes.author_id and merge_request.author_id would be the proper way to verify if the comment author and merge request author are the same

@soulseen
Copy link
Contributor Author

according to https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#comment-on-merge-request

it looks like using object_attributes.author_id and merge_request.author_id would be the proper way to verify if the comment author and merge request author are the same

agree

@jstrachan
Copy link
Member

anyone fancy creating the PR on go-scm to use the correct user id field?

@jeremyrickard
Copy link

Hey @jstrachan i think I have some time this week to take a look (unless @soulseen wants to contribute)

@jstrachan
Copy link
Member

@jeremyrickard that would be totally awesome! ping us on slack if you get stuck with anything

@slimm609
Copy link
Contributor

@jeremyrickard and I talked about it today for a bit, it looks like the fix can be fully solved in go-scm gitlab driver and shouldn't need any changes from lighthouse/lgtm (besides being rebuilt to pick up the changes)

@jstrachan
Copy link
Member

@slimm609 awesome! incidentally whenever go-scm is released there's an automated PR on lighthouse and a new release

@slimm609
Copy link
Contributor

We have a "hacky" fix working to make sure it would fix the issue properly. @soulseen if you want to test in a test environment, you can pull slimm609/test-jx:webhook5 from dockerhub and make sure it works.

It will also log the commenter ID and the author ID to the logs of the webhook container.

Its a little more work to fix it properly but we know how to fix

@soulseen
Copy link
Contributor Author

@slimm609 wonderful! I used it in test env, and it works well.

@jenkins-x-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle stale

@jeremyrickard
Copy link

/remove-lifecycle-stale

@slimm609
Copy link
Contributor

/remove-lifecycle stale

@jeremyrickard
Copy link

I've opened a PR in go-scm to address this. Essentially, when the convertMergeRequestCommentHook method runs, the previous code was just building up a single user object. Really need to fetch both the comment user and the MR user and set them appropriately, to ensure that things are handled properly. This PR adds logic to fetch the user objects (adds a reference to the gitlab user service to do so).

@jstrachan
Copy link
Member

I think this is all fixed now? let me know if not and we can reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants