alphagov / re-request-an-aws-account

:partly_sunny: An interface for requesting AWS accounts
https://request-an-aws-account.gds-reliability.engineering/
1 stars 0 forks source link

Unknown email list error when requesting removal of a subset of a previous rejected PR #325

Open monotypical opened 7 months ago

monotypical commented 7 months ago

I requested the removal of some accounts of people who have left PaaS. This resulted in alphagov/aws-user-management-account-users#1666.

It was then pointed out that one of the people included in the PR is still working with GDS, so that PR was closed.

I then attempted to re-request the removal with the person who is still with GDS excluded, and received the following error from the form:

There is a problem Email list unknown error when opening pull request or sending email

Screenshot 2024-04-04 at 14 17 50 (email addresses redacted from the above screenshot)

I would expect that submitting this second request with a subset of users from the first request would succeed, and result in a second pull request, or at least a more descriptive error if I'm doing something wrong.

stephengrier commented 2 months ago

This issue occurs when two requests are made to add or remove the same user or users. The request-an-aws-account app creates a git branch using a predictable name format eg remove-aws-user-bob-smith-and-friends. When a second request is made for the same user, the request-an-aws-account app tries to create a git branch with the same name, which fails with an error like:

Failed to create branch remove-aws-user-bob-smith-and-friends. Perhaps there’s already a branch with that name?

This error is handled by the create_branch function in the GithubService class, but the app ignores the presence of the error and proceeds with making a call to the Oktokit contents function, which results in an error like:

PUT https://api.github.com/repos/alphagov/aws-user-management-account-users/contents/terraform/gds_users.tf.json: 409 - terraform/gds_users.tf.json does not match 21441be5869329b6d0b63341df20dc5118986573 // See: https://docs.github.com/rest/repos/contents#create-or-update-file-contents

I think the correct fix for this is to change the GithubService class to correctly handle errors from the create_branch call and return a helpful message to the user describing what has likely happened and possibly to check for another request for the same user(s).