From 06d58fe85b1be5752e2fd52acff2e9d519c91f4b Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Fri, 7 Nov 2025 08:17:51 +0200 Subject: [PATCH] Enhance HttpClient error handling for expected 404 responses - Added logic to identify and handle expected 404 errors for conversation participants without logging them as errors. - Updated comments to clarify the expected behavior for cache misses and non-participant status, improving code readability. --- src/core/http.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/core/http.ts b/src/core/http.ts index 14035ea..16f34f0 100644 --- a/src/core/http.ts +++ b/src/core/http.ts @@ -179,8 +179,31 @@ export class HttpClient { } })(); - if (isCacheGetNotFound || isBlockedUsersNotFound) { - // Log cache miss or non-blocked status as debug/info, not error + // "Not found" (404) for conversation_participants is expected behavior - don't log as error + // This happens when checking if a user is a participant (e.g., on first group join) + const isConversationParticipantNotFound = + path === "/v1/rqlite/find-one" && + error instanceof SDKError && + error.httpStatus === 404 && + options.body && + (() => { + try { + const body = + typeof options.body === "string" + ? JSON.parse(options.body) + : options.body; + return body.table === "conversation_participants"; + } catch { + return false; + } + })(); + + if ( + isCacheGetNotFound || + isBlockedUsersNotFound || + isConversationParticipantNotFound + ) { + // Log cache miss, non-blocked status, or non-participant status as debug/info, not error // These are expected behaviors } else { console.error(