Skip to content

Commit

Permalink
Fix contact search - do not throw an error if contact is not found (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelblum authored Sep 12, 2024
1 parent 06c18b7 commit b1cff9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/sweet-geese-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@comet/brevo-api": patch
---

Fix searching contacts

Previously, Brevo returned a 400 error when an email address was not found. The implementation has been updated to correctly handle the 404 status code instead of 400. As a result, the contact search functionality now works as expected without throwing an error when no matching email address is found.
4 changes: 2 additions & 2 deletions packages/api/src/brevo-api/brevo-api-contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class BrevoApiContactsService {
if (!contact) return undefined;
return contact;
} catch (error) {
// Brevo throws 400 error if no contact was found
if (isErrorFromBrevo(error) && error.response.statusCode === 400) {
// Brevo throws 404 error if no contact was found
if (isErrorFromBrevo(error) && error.response.statusCode === 404) {
return undefined;
}
throw error;
Expand Down

0 comments on commit b1cff9b

Please sign in to comment.