fix: allow partial tweet detail errors (#48) (thanks @jsholmes)

This commit is contained in:
Peter Steinberger
2026-01-12 07:33:25 +00:00
parent 35b8774b1c
commit afdcad4f25
3 changed files with 90 additions and 5 deletions
+6 -5
View File
@@ -216,14 +216,15 @@ export function withTweetDetails<TBase extends AbstractConstructor<TwitterClient
};
if (data.errors && data.errors.length > 0) {
// 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;
// Twitter API sometimes returns partial errors (e.g., is_translatable failures)
// alongside valid tweet/thread data. Only fail if nothing useful is present.
const hasUsableData = Boolean(
data.data?.tweetResult?.result ||
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 ?? {} };