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

bugfix: Add check for deleted comments in AzureDevOps event handler #2804

Merged
merged 3 commits into from
Dec 17, 2022
Merged

Conversation

SSKLCP
Copy link
Contributor

@SSKLCP SSKLCP commented Dec 15, 2022

what

Aims to fix bug #2803 which causes Atlantis to ungracefully close a web request when a comment is deleted in a PR.
A simple check to see if the "IsDeleted" property is set to true and return a 200 OK message if so. (ignored)

I've built the project locally with this change and confirm the issue is no longer present when testing in our dev environment.

why

The bug causes Azure DevOps to disable the webhook connector when it sees a web request terminate ungracefully. Effectively bringing down the service until re-enabled.

references

closes #2803

Please let me know if anything else is needed and I'm happy to add - I haven't contributed to any projects this big before 😨

@SSKLCP SSKLCP requested a review from a team as a code owner December 15, 2022 15:06
Copy link
Contributor

@jamengual jamengual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test for this? Thanks

@jamengual jamengual added bug Something isn't working waiting-on-response Waiting for a response from the user labels Dec 15, 2022
@@ -626,6 +626,12 @@ func (e *VCSEventsController) HandleAzureDevopsPullRequestCommentedEvent(w http.
e.respond(w, logging.Debug, http.StatusOK, "Ignoring comment event since no comment is linked to payload; %s", azuredevopsReqID)
return
}

if *resource.Comment.IsDeleted {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think you'd need to add this if block in the AzureDevops VCS section. It's odd that this function exists in the shared events_controller but this if block makes sense where it is then.

I second @jamengual's suggestion to add a test.

We do not currently have any azure devops tests regarding comments but we do for bitbucket and github. If you can follow those as an example, we'd really appreciate azure devops tests.

func TestParseBitbucketServerCommentEvent_EmptyString(t *testing.T) {

Could you add this for azure devops @SSKLCP to validate your change so it doesn't break in the future?

@SSKLCP
Copy link
Contributor Author

SSKLCP commented Dec 16, 2022

@nitrocode / @jamengual - I've added a test in now.

I copied the makings of this function as it seemed closer to the area I was modifying:

func TestPost_AzureDevopsPullRequestIgnoreEvent(t *testing.T) {

I did look at the parser section that you linked however I am not sure that it gets to the ADO parser section in this case, it may be failing before then. (possibly just needs a bit more investigation)

But this test covers the specific case I'm struggling with. Maybe it can be expanded to cover other instances with a blank / null comment once I understand it a bit more.

Copy link
Member

@nitrocode nitrocode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the tests pass, LGTM!

cc: @jamengual

@nitrocode nitrocode removed the waiting-on-response Waiting for a response from the user label Dec 16, 2022
@nitrocode nitrocode merged commit a96a88e into runatlantis:main Dec 17, 2022
@nitrocode
Copy link
Member

Thank you @SSKLCP ! Please feel free to add more changes to azure devops. It's an area that doesn't get too much love. We appreciate you adding tests too. Please add more if time permits.

@jamengual
Copy link
Contributor

+1

nitrocode added a commit to nitrocode/atlantis that referenced this pull request Dec 20, 2022
@nitrocode nitrocode added this to the 0.22.0 milestone Dec 23, 2022
@nitrocode nitrocode changed the title Adding a check for deleted comments in AzureDevOps event handler bugfix: Add check for deleted comments in AzureDevOps event handler Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure DevOps Web Request fails when a PR Comment is Deleted.
3 participants