{"record":{"id":"9b45903d7c9a97a3","repo":"gitroomhq/postiz-app","slug":"handleerror-value-9b4590","errorCode":null,"errorMessage":"${handleError?.value || ''}","messagePattern":"\\$\\{handleError\\?\\.value \\|\\| ''\\}","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts","lineNumber":489,"sourceCode":"    }\n\n    if (status === 'PUBLISH_COMPLETE') {\n      // an empty array is truthy, so index it once and branch on the value\n      const publicPostId = publicaly_available_post_id?.[0];\n\n      return {\n        status: 'completed',\n        releaseURL: !publicPostId\n          ? `https://www.tiktok.com/@${integration.profile}`\n          : `https://www.tiktok.com/@${integration.profile}/video/${publicPostId}`,\n        // TikTok returns the id as a number, releaseId in the db is a string\n        postId: !publicPostId ? pendingData.publishId : String(publicPostId),\n      };\n    }\n\n    if (status === 'FAILED') {\n      const handleError = this.handleErrors(JSON.stringify(post));\n      throw new BadBody(\n        'titok-error-upload',\n        JSON.stringify(post),\n        Buffer.from(JSON.stringify(post)),\n        handleError?.value || ''\n      );\n    }\n\n    return { status: 'pending', pendingData };\n  }\n\n  // UPLOAD does not publish - it only drops the media into the user's TikTok\n  // inbox - so only an explicit UPLOAD selects it. A missing value (drafts, or\n  // any caller that skipped the setting) publishes instead of silently landing\n  // in the inbox.\n  private contentPostingMethod(\n    firstPost: PostDetails<TikTokDto>\n  ): TikTokDto['content_posting_method'] {\n    return firstPost?.settings?.content_posting_method === 'UPLOAD'","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/tiktok.provider.ts#L471-L507","documentation":"The non-business TikTok provider's checkPostStatus: when the direct-post poll returns status === 'FAILED', a BadBody ('titok-error-upload') is thrown with handleErrors' classified message or ''. TikTok definitively failed to publish the video.","triggerScenarios":"Direct post ends in FAILED: video violates policy, is unplayable/corrupt, or the upload/publish parameters (privacy, music, hashtags) were rejected during async processing.","commonSituations":"Content moderation rejections, unsupported video codecs, or drafts never finalized within TikTok's processing window (note the typo'd identifier 'titok-error-upload').","solutions":["Check the logged post JSON for the failure field detail","Re-encode the video to H.264/AAC MP4 and retry","Ensure post parameters (privacy, disables) are valid for the app's scopes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-flight: validate the uploaded video before scheduling the post\nconst ok = await ffprobeIsH264Mp4(video.url);\nif (!ok) throw new Error('Re-encode video to H.264 MP4 before posting to TikTok');","typeGuard":"const isFailedStatus = (s?: string): s is 'FAILED' => s === 'FAILED';","tryCatchPattern":"try { await provider.check(post); } catch (e) { if (e instanceof BadBody && /titok-error-upload/.test(e.error)) markPostFailed(post, e.error); throw e; }","preventionTips":["Standardize uploads on H.264/AAC MP4","Surface the API failure detail to users","Avoid moderation-triggering content in scheduled posts"],"tags":["tiktok","post-failed","video-upload","moderation"],"backgroundTag":"social-post-rejected","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}