Skip to content

a8n: Implement retryCampaign mutation

Created by: mrnugget

This is a follow-up to RFC 42.

Right now, when the createCampaign mutation with a given CampaignPlan ID fails due to various reasons (GitHub not reachable, token invalid, gitserver down, ...) the conversion of ChangesetJobs into Changesets in the (&a8n.Service).runChangesetJob ends with the ChangesetJobs having its Error field populated. See the code here

What we want is a retryCampaign mutation that

  • takes in a Campaign ID
  • loads all the failed ChangesetJobs (definition: finished_at is null, or error is non-blank, or changeset_id is null)
  • uses (&a8n.Service).runChangesetJob to try again to create a commit from the given diff in the connected CampaignJob, push the commit, open a pull request on the codehost, save the pull request as an external service

Important: for that to work, the runChangesetJob method must be idempotent! That means: if it runs twice with the same ChangesetJob is cannot create duplicate pull requests!. That means it needs to check that new commits are not added to same branch, check for ErrAlreadyExists response from code hosts, early-exit if a Changset with the given changeset_job_id exists, etc.