Skip to content

Commit 96e46cf

Browse files
giladresisiclaude
andcommitted
fix(tiktok): correct picture_size_check_failed message and pre-check image sizes
TikTok returns fail_reason `picture_size_check_failed` when media violates its size rules, and we mapped it to "Video must be at least 720p, Picture must no exceed 1080p". Both halves were wrong or unhelpful: TikTok documents no minimum for photos, "1080p" never said which dimension, and the 720p video claim has no basis in the docs. A customer hit this on TikTok carousels created through the public API. Her images were 941x1672 (valid), but each failing carousel also contained a 1086x1448 image - 6px over the 1080 limit on the shorter side - and a single oversized image fails the entire carousel. TikTok never reports which image failed, so the generic message sent her resizing images that were already fine. Verified against the real API on a connected TikTok channel, uploading through the public API so the media reaches TikTok at its original dimensions: 480x640 -> PUBLISHED (disproves the "at least 720p" claim) 320x320 -> FAILED (picture_size_check_failed, confirms the 360 floor) 5000x5000 -> PUBLISHED (TikTok does not enforce its documented 4096 max) The message therefore claims only what was verified: the 1080 image ceiling and the 360 video floor. The documented 4096 ceiling is omitted because TikTok accepted a 5000x5000 video. `checkValidity` now measures photos up front and names the offending image, so the failure surfaces at save time instead of hours later at publish. It mirrors the existing Pinterest check and reuses `getImageDimensions`. Videos are not pre-checked: there is no ffmpeg dependency server-side, so video size still only surfaces at publish through the corrected message. Already-scheduled carousels are not re-validated - `checkValidity` only runs on create/update - so existing invalid posts will still fail at publish, now with the corrected message. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent cef5d2e commit 96e46cf

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
6767
) {
6868
return 'You need one media';
6969
}
70+
71+
// TikTok fails the whole photo post when a single image is oversized, and
72+
// the status only says `picture_size_check_failed` without naming it.
73+
if (firstItems?.every((p) => (p?.path?.indexOf?.('mp4') ?? -1) === -1)) {
74+
const dimensions = await Promise.all(
75+
firstItems?.map((p) => this.getImageDimensions(p?.path)) ?? []
76+
);
77+
const tooBig = dimensions.findIndex(
78+
(p) => Math.min(p?.width ?? 0, p?.height ?? 0) > 1080
79+
);
80+
if (tooBig > -1) {
81+
return `Image ${tooBig + 1} is ${dimensions[tooBig]?.width}x${
82+
dimensions[tooBig]?.height
83+
}, TikTok allows a maximum of 1080px on the shorter side`;
84+
}
85+
}
7086
return true;
7187
}
7288

@@ -255,7 +271,8 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
255271
if (body.indexOf('picture_size_check_failed') > -1) {
256272
return {
257273
type: 'bad-body' as const,
258-
value: 'Video must be at least 720p, Picture must no exceed 1080p',
274+
value:
275+
'Media size not supported by TikTok: images up to 1080px on the shorter side, videos at least 360px on both sides',
259276
};
260277
}
261278

0 commit comments

Comments
 (0)