From 35b8774b1c396679c2174d34985b77be28896832 Mon Sep 17 00:00:00 2001 From: John Holmes Date: Sun, 11 Jan 2026 21:33:25 -0500 Subject: [PATCH] fix: handle partial errors in TweetDetail API responses Twitter API sometimes returns partial errors (e.g., is_translatable field failures) alongside valid thread data. Previously, any error caused the entire request to fail even when usable data was present. Now we check if threaded_conversation_with_injections_v2.instructions exists before failing on errors, allowing successful thread fetching despite non-fatal API errors. Co-Authored-By: Claude Opus 4.5 --- src/lib/twitter-client-tweet-detail.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/twitter-client-tweet-detail.ts b/src/lib/twitter-client-tweet-detail.ts index c9cb016..fa3ba2b 100644 --- a/src/lib/twitter-client-tweet-detail.ts +++ b/src/lib/twitter-client-tweet-detail.ts @@ -216,7 +216,14 @@ export function withTweetDetails 0) { - return { success: false as const, error: data.errors.map((e) => e.message).join(', ') }; + // Check if we still have usable data despite errors. + // Twitter API sometimes returns partial errors (e.g., is_translatable field failures) + // alongside valid thread data. Only fail if no usable data is present. + const hasUsableData = data.data?.threaded_conversation_with_injections_v2?.instructions?.length; + if (!hasUsableData) { + return { success: false as const, error: data.errors.map((e) => e.message).join(', ') }; + } + // Continue with partial data despite non-fatal errors } return { success: true as const, data: data.data ?? {} };