From 854d31168d0bdb04c5c90dd2de01fa765fc620e7 Mon Sep 17 00:00:00 2001 From: G Date: Tue, 21 Apr 2026 16:24:44 -0400 Subject: [PATCH] fix: treat missing instagram thread as already deleted When deleting an Instagram chat that was already removed on the native app, the route definition endpoint returns 200 but with an empty thread_fbid. Previously this caused a FAIL_RETRIABLE error loop since the bridge kept retrying a deletion that could never succeed. Add ErrIGThreadNotFound sentinel error to fetchRouteDefinition so DeleteThread can detect this case with errors.Is and return nil, allowing the client to clean up the room locally. Fixes PLAT-36131 --- pkg/messagix/instagram.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/messagix/instagram.go b/pkg/messagix/instagram.go index 32668237..bc647e4d 100644 --- a/pkg/messagix/instagram.go +++ b/pkg/messagix/instagram.go @@ -25,6 +25,10 @@ import ( "go.mau.fi/mautrix-meta/pkg/messagix/useragent" ) +// ErrIGThreadNotFound is returned when a route definition request succeeds +// but the thread_fbid is missing, indicating the thread no longer exists on Instagram. +var ErrIGThreadNotFound = errors.New("instagram thread not found") + // specific methods for insta api, not socket related type InstagramMethods struct { client *Client @@ -255,7 +259,7 @@ func (ig *InstagramMethods) fetchRouteDefinition(ctx context.Context, threadID s } threadFBID := routeDefResp.Payload.Result.Exports.RootView.Props.ThreadFBID if threadFBID == "" { - return "", fmt.Errorf("thread_fbid not found in route definition response for thread %s", threadID) + return "", fmt.Errorf("%w in route definition response for thread %s", ErrIGThreadNotFound, threadID) } zerolog.Ctx(ctx).Info(). @@ -269,6 +273,11 @@ func (ig *InstagramMethods) fetchRouteDefinition(ctx context.Context, threadID s func (ig *InstagramMethods) DeleteThread(ctx context.Context, threadID string) error { id, err := ig.fetchRouteDefinition(ctx, threadID) if err != nil { + if errors.Is(err, ErrIGThreadNotFound) { + zerolog.Ctx(ctx).Warn().Err(err).Str("thread_id", threadID). + Msg("Thread not found on Instagram, assuming already deleted") + return nil + } return fmt.Errorf("failed to fetch route definition for thread %s: %w", threadID, err) } igVariables := &graphql.IGDeleteThreadGraphQLRequestPayload{