Skip to content

Commit f3f8215

Browse files
Bill Leoutsakoscursoragent
authored andcommitted
fix(tiktok): lower upload memory cap, drop redundant avatar string outputs
Cap the file-upload video buffer at 250MB instead of TikTok's 4GB ceiling — relaying that much through this server's memory per request isn't safe under concurrent load, and larger files can still go through the PULL_FROM_URL path, which never buffers on our server. Also drop the now-redundant avatarUrl/avatarUrl100/avatarLargeUrl string outputs from Get User Info in favor of the file-typed avatarFile output alone, since the feature is unreleased and the raw URL is still reachable via avatarFile.url. Cover image URLs on List/Query Videos are confirmed to be signed, expiring TikTok CDN links; left as strings (no file-output conversion path exists for fields nested inside array items) but documented the expiry behavior more clearly. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 909144b commit f3f8215

7 files changed

Lines changed: 18 additions & 53 deletions

File tree

apps/docs/content/docs/en/integrations/tiktok.mdx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ Get the authenticated TikTok user profile information including display name, av
3535
| `openId` | string | Unique TikTok user ID for this application |
3636
| `unionId` | string | Unique TikTok user ID across all apps from the same developer |
3737
| `displayName` | string | User display name |
38-
| `avatarUrl` | string | Profile image URL |
39-
| `avatarUrl100` | string | Profile image URL \(100x100\) |
40-
| `avatarLargeUrl` | string | Profile image URL \(large\) |
4138
| `bioDescription` | string | User bio description |
4239
| `profileDeepLink` | string | Deep link to user TikTok profile |
4340
| `isVerified` | boolean | Whether the account is verified |
@@ -66,7 +63,7 @@ Get a list of the authenticated user's TikTok videos with cover images, titles,
6663
| `videos` | array | List of TikTok videos |
6764
|`id` | string | Video ID |
6865
|`title` | string | Video title |
69-
|`coverImageUrl` | string | Cover image URL \(may expire\) |
66+
|`coverImageUrl` | string | Signed cover image URL from TikTok CDN. Publicly fetchable without auth, but time-limited \(embeds an x-expires param\) — use it right away rather than storing it for later. |
7067
|`embedLink` | string | Embeddable video URL |
7168
|`duration` | number | Video duration in seconds |
7269
|`createTime` | number | Unix timestamp when video was created |
@@ -98,7 +95,7 @@ Query specific TikTok videos by their IDs to get fresh metadata including cover
9895
| `videos` | array | List of queried TikTok videos |
9996
|`id` | string | Video ID |
10097
|`title` | string | Video title |
101-
|`coverImageUrl` | string | Cover image URL \(fresh URL\) |
98+
|`coverImageUrl` | string | Signed cover image URL from TikTok CDN. Publicly fetchable without auth, but time-limited \(embeds an x-expires param\) — use it right away rather than storing it for later. |
10299
|`embedLink` | string | Embeddable video URL |
103100
|`duration` | number | Video duration in seconds |
104101
|`createTime` | number | Unix timestamp when video was created |

apps/sim/app/api/tools/tiktok/publish-video/route.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ const TIKTOK_VIDEO_MIME_TYPES = new Set(['video/mp4', 'video/quicktime', 'video/
2525
/** TikTok requires each chunk between 5MB and 64MB; the final chunk absorbs the remainder (up to ~2x this size, well under the 128MB cap). Capped at 1000 chunks total, which this default comfortably satisfies up to TikTok's 4GB video size limit. */
2626
const DEFAULT_CHUNK_SIZE = 10_000_000
2727

28-
/** TikTok's documented maximum video file size. Enforced before downloading the file into
29-
* memory so an oversized upload fails fast instead of materializing multiple GB in-process. */
30-
const TIKTOK_MAX_VIDEO_BYTES = 4 * 1024 * 1024 * 1024
28+
/** Maximum size this route will buffer in memory for a single file-upload request. TikTok's
29+
* own limit is 4GB, but relaying that much through this server's memory per request isn't
30+
* safe under concurrent load. Enforced before downloading the file so an oversized upload
31+
* fails fast with a clean 413 instead of materializing hundreds of MB to multiple GB
32+
* in-process. Users with larger files can use the "Public URL" source instead, since
33+
* PULL_FROM_URL never routes bytes through this process. */
34+
const TIKTOK_MAX_VIDEO_BYTES = 250 * 1024 * 1024
3135

3236
function computeChunkPlan(totalBytes: number): { chunkSize: number; totalChunkCount: number } {
3337
if (totalBytes <= DEFAULT_CHUNK_SIZE) {
@@ -193,8 +197,12 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
193197
maxBytes: error.maxBytes,
194198
observedBytes: error.observedBytes,
195199
})
200+
const maxMb = Math.floor(TIKTOK_MAX_VIDEO_BYTES / (1024 * 1024))
196201
return NextResponse.json(
197-
{ success: false, error: `Video exceeds TikTok's maximum file size of 4GB` },
202+
{
203+
success: false,
204+
error: `Video exceeds the ${maxMb}MB limit for file uploads. Use a public video URL instead to post larger files.`,
205+
},
198206
{ status: 413 }
199207
)
200208
}

apps/sim/blocks/blocks/tiktok.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -529,21 +529,6 @@ export const TikTokBlock: BlockConfig<TikTokResponse> = {
529529
description: 'User display name',
530530
condition: { field: 'operation', value: 'tiktok_get_user' },
531531
},
532-
avatarUrl: {
533-
type: 'string',
534-
description: 'Profile image URL',
535-
condition: { field: 'operation', value: 'tiktok_get_user' },
536-
},
537-
avatarUrl100: {
538-
type: 'string',
539-
description: 'Profile image URL (100x100)',
540-
condition: { field: 'operation', value: 'tiktok_get_user' },
541-
},
542-
avatarLargeUrl: {
543-
type: 'string',
544-
description: 'Profile image URL (large)',
545-
condition: { field: 'operation', value: 'tiktok_get_user' },
546-
},
547532
bioDescription: {
548533
type: 'string',
549534
description: 'User bio description',

apps/sim/tools/tiktok/get_user.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ export const tiktokGetUserTool: ToolConfig<TikTokGetUserParams, TikTokGetUserRes
5454
openId: '',
5555
unionId: null,
5656
displayName: '',
57-
avatarUrl: null,
58-
avatarUrl100: null,
59-
avatarLargeUrl: null,
6057
bioDescription: null,
6158
profileDeepLink: null,
6259
isVerified: null,
@@ -79,9 +76,6 @@ export const tiktokGetUserTool: ToolConfig<TikTokGetUserParams, TikTokGetUserRes
7976
openId: '',
8077
unionId: null,
8178
displayName: '',
82-
avatarUrl: null,
83-
avatarUrl100: null,
84-
avatarLargeUrl: null,
8579
bioDescription: null,
8680
profileDeepLink: null,
8781
isVerified: null,
@@ -104,9 +98,6 @@ export const tiktokGetUserTool: ToolConfig<TikTokGetUserParams, TikTokGetUserRes
10498
openId: user.open_id ?? '',
10599
unionId: user.union_id ?? null,
106100
displayName: user.display_name ?? '',
107-
avatarUrl: user.avatar_url ?? null,
108-
avatarUrl100: user.avatar_url_100 ?? null,
109-
avatarLargeUrl: user.avatar_large_url ?? null,
110101
bioDescription: user.bio_description ?? null,
111102
profileDeepLink: user.profile_deep_link ?? null,
112103
isVerified: user.is_verified ?? null,
@@ -140,21 +131,6 @@ export const tiktokGetUserTool: ToolConfig<TikTokGetUserParams, TikTokGetUserRes
140131
type: 'string',
141132
description: 'User display name',
142133
},
143-
avatarUrl: {
144-
type: 'string',
145-
description: 'Profile image URL',
146-
optional: true,
147-
},
148-
avatarUrl100: {
149-
type: 'string',
150-
description: 'Profile image URL (100x100)',
151-
optional: true,
152-
},
153-
avatarLargeUrl: {
154-
type: 'string',
155-
description: 'Profile image URL (large)',
156-
optional: true,
157-
},
158134
bioDescription: {
159135
type: 'string',
160136
description: 'User bio description',

apps/sim/tools/tiktok/list_videos.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export const tiktokListVideosTool: ToolConfig<TikTokListVideosParams, TikTokList
9292
title: { type: 'string', description: 'Video title', optional: true },
9393
coverImageUrl: {
9494
type: 'string',
95-
description: 'Cover image URL (may expire)',
95+
description:
96+
'Signed cover image URL from TikTok CDN. Publicly fetchable without auth, but time-limited (embeds an x-expires param) — use it right away rather than storing it for later.',
9697
optional: true,
9798
},
9899
embedLink: { type: 'string', description: 'Embeddable video URL', optional: true },

apps/sim/tools/tiktok/query_videos.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export const tiktokQueryVideosTool: ToolConfig<TikTokQueryVideosParams, TikTokQu
8787
title: { type: 'string', description: 'Video title', optional: true },
8888
coverImageUrl: {
8989
type: 'string',
90-
description: 'Cover image URL (fresh URL)',
90+
description:
91+
'Signed cover image URL from TikTok CDN. Publicly fetchable without auth, but time-limited (embeds an x-expires param) — use it right away rather than storing it for later.',
9192
optional: true,
9293
},
9394
embedLink: { type: 'string', description: 'Embeddable video URL', optional: true },

apps/sim/tools/tiktok/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ export interface TikTokGetUserResponse extends ToolResponse {
2020
openId: string
2121
unionId: string | null
2222
displayName: string
23-
avatarUrl: string | null
24-
avatarUrl100: string | null
25-
avatarLargeUrl: string | null
2623
bioDescription: string | null
2724
profileDeepLink: string | null
2825
isVerified: boolean | null

0 commit comments

Comments
 (0)