Skip to content

fix: check person exists in CRMs before trying to tag them#99

Merged
joaquimds merged 1 commit into
masterfrom
fix/check-exists-before-tag
May 13, 2026
Merged

fix: check person exists in CRMs before trying to tag them#99
joaquimds merged 1 commit into
masterfrom
fix/check-exists-before-tag

Conversation

@joaquimds
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent CRM tagging operations from creating or erroring on non-existent people/members by adding existence checks before applying tags in Mailchimp and Action Network.

Changes:

  • Mailchimp: skip addTag / removeTag when the member is not found.
  • Action Network: add personExists() and skip addTag / removeTag when the person is not found.
  • Action Network: log the outgoing signup payload.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/join-block/src/Services/MailchimpService.php Adds a Mailchimp member existence pre-check before tag updates.
packages/join-block/src/Services/ActionNetworkService.php Adds Action Network person existence lookup before tag updates and logs signup payload.
Comments suppressed due to low confidence (1)

packages/join-block/src/Services/MailchimpService.php:285

  • Same as addTag(): removeTag() now does a preflight memberExists() lookup, adding an extra Mailchimp API call per operation. Consider handling the 404/not-found case in the updateListMemberTags catch instead, so you can skip missing members without doubling requests.
        if (!self::memberExists($email)) {
            $joinBlockLog->warning("Skipping Mailchimp removeTag('$tag') for $email: member does not exist");
            return;
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

];
}

$joinBlockLog->info("Action Network payload for {$data['email']}: " . json_encode($anData));
Comment on lines +128 to +132
],
"query" => [
"filter" => "email_address eq '" . $email . "'"
]
]
Comment on lines +118 to +137
public static function personExists($email)
{
$client = new Client();

$response = $client->request(
"GET",
"https://actionnetwork.org/api/v2/people/",
[
"headers" => [
"OSDI-API-Token" => Settings::get("ACTION_NETWORK_API_KEY")
],
"query" => [
"filter" => "email_address eq '" . $email . "'"
]
]
);

$data = json_decode($response->getBody()->getContents(), true);
return !empty($data["_embedded"]["osdi:people"]);
}
Comment on lines +255 to +258
if (!self::memberExists($email)) {
$joinBlockLog->warning("Skipping Mailchimp addTag('$tag') for $email: member does not exist");
return;
}
@joaquimds joaquimds merged commit 6b62a74 into master May 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants