zapier/tfbuddy

Duplicate MR comments posted when running `tfc plan` or `tfc apply`

ahinh43 opened this issue · 1 comments

When tfbuddy kicks off its normal workflow it starts posting duplicate messages, typically 2 or more times in one message thread. They don't seem to point to creating entirely different runs thankfully but it can get very confusing and very spammy as there can be upwards of 4 or 5 messages being posted after sending a single tfc plan or tfc apply command in the MR.

This issue only started appearing after we upgraded to the 0.20.0 release. I haven't noticed this issue in 0.17.0. Additionally, I've only tested this on Gitlab so far, I have not tried this in Github yet.

Steps to reproduce (on Gitlab)

  1. Clone the main branch
  2. Start the localdev environment with tilt up
  3. Open gitlab.com and navigate to the generated test repository
  4. Create a merge request using the test branch that tilt created
  5. tfc plan should automatically run, generating duplicate plan messages
  6. Comment tfc apply to the MR and let tfbuddy apply the MR. It should respond multiple times that the apply was a success.

Image for reference

image

As I continue to look into the behavior of this bug I found an interesting case for Gitlab:

It looks like the behavior only appears when there is no merge request pipeline in the repository. If you add a simple .gitlab-ci.yml file and ensure one or more jobs in it are set for a merge request pipeline the duplicate messaging stops.

I think it might have to do with how the pipeline ID retry logic works? It does look like we are returning nil when we fetch pipelines since we only filter for MR pipelines which triggers a retry. I don't know how the gitlab action logic is supposed to work though.

I do have test pipelines folks can view, but they are zapier internal pipelines and URLs and I'm not sure if I can post them here. Feel free to reach out to me on slack and i'll be happy to share more details!