From 0962b070216d7de931c0302afbc80c9b51ddfba5 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 6 Oct 2024 14:04:06 +0200 Subject: [PATCH] [backend/core] Catch errors in NoteService.ResolveNoteAsync This fixes some inbox job failures, for example when a post quoting a deleted post is being ingested. --- .../Federation/ActivityPub/ActivityFetcherService.cs | 2 +- Iceshrimp.Backend/Core/Services/NoteService.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs index f9f391bd..7d913cbe 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs @@ -185,7 +185,7 @@ public class ActivityFetcherService( if (!response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.Gone) - throw AuthFetchException.NotFound("The remote user no longer exists."); + throw AuthFetchException.NotFound("The remote object no longer exists."); logger.LogDebug("Failed to fetch activity: response status was {code}", response.StatusCode); return null; } diff --git a/Iceshrimp.Backend/Core/Services/NoteService.cs b/Iceshrimp.Backend/Core/Services/NoteService.cs index 71955be4..ce62660f 100644 --- a/Iceshrimp.Backend/Core/Services/NoteService.cs +++ b/Iceshrimp.Backend/Core/Services/NoteService.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Net; using AsyncKeyedLock; using Iceshrimp.Backend.Core.Configuration; using Iceshrimp.Backend.Core.Database; @@ -1141,6 +1142,16 @@ public class NoteService( var id = e.Uri[$"https://{config.Value.WebDomain}/notes/".Length..]; return await db.Notes.IncludeCommonProperties().FirstOrDefaultAsync(p => p.Id == id); } + catch (AuthFetchException e) when (e.StatusCode == HttpStatusCode.NotFound) + { + logger.LogDebug("Failed to fetch note, skipping: {error}", e.Message); + return null; + } + catch (Exception e) + { + logger.LogDebug("Failed to fetch note, skipping: {error}", e); + return null; + } if (fetchedNote == null) {