Automattic / Automattic/jetpack
Mailchimp block: Form instances with deleted group attributes result in failed subscribe requests
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
#### Steps to reproduce the issue
1. Make sure you have a WP site connected to a valid Mailchimp account and list.
2. Log into the Mailchimp account and go to **Audience > All contacts > Manage contacts > Groups**. Make sure the list you're editing is the list you connected to Jetpack.

3. Click **Create Groups** and create a group for the list that's connected via Jetpack.
4. On the connected WP site, add a Mailchimp block to a post or page. In the block's sidebar attributes, expand **Mailchimp Groups** and select the group you just created (it might take a few seconds to appear). Update.

5. View the post/page front-end. Enter a real email address and confirm that the subscribe request works and returns a success message.
6. On the Mailchimp side, go to **Audience > All contacts** and verify that your email address has been subscribed to your list, assigned to the selected group.
7. Still in Mailchimp, go back to **Manage contacts > Groups** and click **View Groups**. Next to the test group click "Delete" and follow the steps to delete the group.

8. In WP, refresh the editor page for the post or page where you added the Mailchimp block. Expand the **Mailchimp Groups** sidebar panel and observe that the group is no longer shown here (because the list of groups to show as options is fetched directly from Mailchimp, where the group was deleted).
9. View the post/page front-end. Enter another real email address, and this time observe that the subscribe request fails with an error message.

10. If you inspect the request in **Dev Tools > Network**, you should see a response something like this:
```
{
"error": "invalid_resource",
"message": "Mailchimp Error: Invalid interest ID: ''."
}
```
#### What I expected
If the Mailchimp block's `interests` attribute contains an ID that is not contained in the response from Mailchimp to fetch all groups/interests, then that ID should either be shown as deleted in the sidebar and not sent as part of the subscribe request, or purged entirely.
On the front-end, if the response from Mailchimp is an `invalid_resource` error, the request should be retried without the group ID returned in the response (or without any groups, if the response doesn't contain an ID) to minimize failure for potential subscribers.
#### What happened instead
The error happens because the group no longer exists on the Mailchimp side, so its API rejects the request. However, the group ID is still stored in the block's `interests` attribute, and will be sent with every signup request. Furthermore, because the list of group options in the editor is fetched from Mailchimp, there's now no indication that a group is selected in the block's attributes, and no way to remove the selected group without destroying the block instance and rebuilding from scratch.
Contributor guide
Research direction
No files or tests are named. Start by locating the Mailchimp block's interests attribute, the editor's group-fetching logic, and the front-end subscribe request; reproduce the deleted-group scenario described above. Done means deleted group IDs are no longer submitted, and invalid_resource responses are handled according to the issue's expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php, wordpress
- Domain
- api, backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100