From bc99867c2250697edef7631eec05e33ef6364cb2 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 18 Feb 2026 21:56:51 -0800 Subject: [PATCH] =?UTF-8?q?Avoid=20force-unwrapping=20=E2=80=94=C2=A0fix?= =?UTF-8?q?=20a=20crash.=20Fixes=20#5128.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Account/ReaderAPI/ReaderAPICaller.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift index e8063cfb1..3203cfc17 100644 --- a/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift +++ b/Modules/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift @@ -407,15 +407,21 @@ enum CreateReaderAPISubscriptionResult { request.httpMethod = "POST" // Get ids from above into hex representation of value - let idsToFetch = articleIDs.map({ articleID -> String in + let idsToFetch = articleIDs.compactMap({ articleID -> String? in if self.variant == .theOldReader { return "i=tag:google.com,2005:reader/item/\(articleID)" } else { - let idValue = Int(articleID)! - let idHexString = String(idValue, radix: 16, uppercase: false) - return "i=tag:google.com,2005:reader/item/\(idHexString)" + if let idValue = Int(articleID) { + let idHexString = String(idValue, radix: 16, uppercase: false) + return "i=tag:google.com,2005:reader/item/\(idHexString)" + } else { + return nil + } } }).joined(separator: "&") + if idsToFetch.isEmpty { + return nil + } let postData = Data("T=\(token)&output=json&\(idsToFetch)".utf8)