{"record":{"id":"2e29a9656911d405","repo":"gitroomhq/postiz-app","slug":"handleerror-value-2e29a9","errorCode":null,"errorMessage":"${handleError?.value || ''}","messagePattern":"\\$\\{handleError\\?\\.value \\|\\| ''\\}","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts","lineNumber":500,"sourceCode":"      // post_ids can lag up to 3 minutes behind PUBLISH_COMPLETE, and never\n      // shows up at all for non-public posts - fall back to the profile URL\n      // and keep the share_id (postAnalytics resolves it later).\n      const publicPostId = post_ids?.[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        postId: !publicPostId ? pendingData.publishId : String(publicPostId),\n      };\n    }\n\n    if (status === 'FAILED') {\n      const handleError = this.handleErrors(\n        `${reason || ''} ${JSON.stringify(post)}`\n      );\n      throw new BadBody(\n        'tiktok-business-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 as a draft - so only an explicit UPLOAD selects it. A missing value\n  // (drafts, or any caller that skipped the setting) publishes instead of\n  // silently landing in the inbox.\n  private contentPostingMethod(\n    firstPost: PostDetails<TikTokDto>\n  ): TikTokDto['content_posting_method'] {\n    return firstPost?.settings?.content_posting_method === 'UPLOAD'","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts#L482-L518","documentation":"checkPostStatus sees status === 'FAILED' in the TikTok Business direct-post status body. It runs handleErrors on the reason plus full JSON and throws BadBody with the classified message (or empty string fallback), meaning TikTok definitively rejected the video.","triggerScenarios":"Direct post fails TikTok's asynchronous review: policy violation, corrupted/unplayable video, privacy setting rejected, or video stuck processing then failed.","commonSituations":"Videos with copyrighted music, content flagged by moderation, unsupported codecs, or draft posts left beyond TikTok's processing window.","solutions":["Inspect the logged post JSON - the reason field names the failure cause","Fix the video (codec/format/content) and re-upload","If privacy=SELF_ONLY draft, ensure the post completes within the allowed window"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-validate video before scheduling\nconst probe = await ffprobe(video);\nif (probe.codec !== 'h264' || probe.duration > 600) throw new Error('Video not suitable for TikTok');","typeGuard":"const isFailedStatus = (s?: string): s is 'FAILED' => s === 'FAILED';","tryCatchPattern":"try { await provider.check(post); } catch (e) { if (e instanceof BadBody && /tiktok-business-error-upload/.test(e.error)) markPostFailedWithReason(post, e.error); throw e; }","preventionTips":["Pre-encode uploads to TikTok-friendly H.264 MP4","Avoid content likely to trip moderation (music, restricted topics)","Show the API reason field to end users for actionable feedback"],"tags":["tiktok","post-failed","moderation","video-upload"],"backgroundTag":"social-post-rejected","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}