fix: allow partial tweet detail errors (#48) (thanks @jsholmes)
This commit is contained in:
@@ -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 ?? {} };
|
||||
|
||||
Reference in New Issue
Block a user