Skip to content

Commit 21f85f2

Browse files
committed
fix(webapp): treat Loops 404 as successful contact deletion
When deleting a Loops contact, a 404 response indicates the contact doesn’t exist, which is already the desired end state. Handle this explicitly by returning true instead of falling through to the generic error path. - Treat HTTP 404 from Loops delete endpoint as success - Add test coverage for the 404 case
1 parent 0c6a725 commit 21f85f2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

apps/webapp/app/services/loops.server.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export class LoopsClient {
4343
body: JSON.stringify({ email }),
4444
});
4545

46+
if (response.status === 404) {
47+
this.#logger.info(`Loops contact already deleted`, { email });
48+
return true;
49+
}
50+
4651
if (!response.ok) {
4752
this.#logger.error(`Loops deleteContact bad status`, { status: response.status, email });
4853
return false;

apps/webapp/test/loopsClient.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ describe("LoopsClient", () => {
5858
expect(result).toBe(true);
5959
});
6060

61+
it("should return true when API returns 404 (contact already deleted)", async () => {
62+
mockFetch.mockResolvedValueOnce({
63+
ok: false,
64+
status: 404,
65+
});
66+
67+
const client = new LoopsClient("test-api-key", noopLogger);
68+
const result = await client.deleteContact({ email: "test@example.com" });
69+
70+
expect(result).toBe(true);
71+
});
72+
6173
it("should return false on API error (500)", async () => {
6274
mockFetch.mockResolvedValueOnce({
6375
ok: false,

0 commit comments

Comments
 (0)