Skip to content

chore(tiktok): log fail_reason when a post stays in progress - #1883

Open
giladresisi wants to merge 1 commit into
mainfrom
fix/tiktok-status-fail-reason
Open

chore(tiktok): log fail_reason when a post stays in progress#1883
giladresisi wants to merge 1 commit into
mainfrom
fix/tiktok-status-fail-reason

Conversation

@giladresisi

@giladresisi giladresisi commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What kind of change does this PR introduce?

Logging only, for troubleshooting. No behaviour change.

Why was this change needed?

Multiple users are hitting the same TikTok failure: the post is accepted by TikTok and comes back with a publish id, but every subsequent status check reports the post as still in progress for the entire 30 minute polling window. It never reaches PUBLISH_COMPLETE and it is never returned as FAILED, so we exhaust the checks and mark the post as unconfirmed, which is all the user sees.

These posts do not appear to publish at all. One affected user posts image carousels to their TikTok inbox and reports the content never arrives there; another hits the same thing with direct posts. So the format is common to both, the posting method is not, and in every case TikTok gives us no reason we could show the user.

TikTok's status response includes a fail_reason field alongside status. Today we only benefit from it on FAILED, where handleErrors already matches the spam_risk* values and surfaces them; on every other status we read status and drop the rest. If TikTok ever populates fail_reason while still reporting the post as in progress, that is exactly the explanation we have been missing, and it would also give us a stop condition for the polling instead of waiting out the full window and giving up.

This logs the field only on the path that returns "still pending" - after the two success branches and after FAILED - so nothing is logged when the API behaves as documented. It is a no-op in the healthy case.

Other information:

Deliberately observe-only. The value is logged and nothing acts on it, because failing a post on an undocumented signal could kill publishes that would otherwise have completed. Once we have real values we can decide whether to end the polling early on it.

Trade-offs worth knowing:

  • If it does fire, a single stuck post can log up to 90 lines, one per poll (maxPendingChecks = 90 at 20 second intervals). Noisy per incident, but only in the case we want to see, and these are rare.
  • We will not see fail_reason if it only ever arrives on a status we treat as successful. That is intentional: the post published either way, so it would be logging for nothing.

Reference: https://developers.tiktok.com/doc/content-posting-api-reference-get-video-status

Checklist:

Put a "X" in the boxes below to indicate you have followed the checklist;

  • I have read the CONTRIBUTING guide.
  • I have signed the Contributor License Agreement (CLA) (ICLA for individuals, CCLA for entities).
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were no similar issues or PRs already open for this.
  • This PR fixes just ONE issue

Several users reported TikTok posts that Postiz marked as unconfirmed:
the publish is accepted and returns a publish id, but every status check
comes back in a processing state for the full 30 minute polling window,
never PUBLISH_COMPLETE and never FAILED. Their TikTok inboxes show the
content never arrived, so these posts were not published after all, and
we have nothing to tell the user beyond "we could not confirm it".

TikTok's status response carries a fail_reason field next to the status.
We only read it on FAILED today, where handleErrors already surfaces it,
and discard it everywhere else. If TikTok ever populates it while still
reporting progress, that is the explanation we are missing, and a
possible stop condition for the polling instead of waiting out the full
window.

Log it only on the path that returns "still pending", so nothing is
logged on either success branch or on FAILED. The line is a no-op while
the API behaves as documented, and the polling behaviour is unchanged -
this only observes, it does not act on the field.
@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label Aug 12, 2026
@postiz-agent

postiz-agent Bot commented Aug 12, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@giladresisi giladresisi changed the title chore(tiktok): log fail_reason when a post stays in progress chore(tiktok): log the status response while a post is still in progress Aug 12, 2026
@giladresisi
giladresisi force-pushed the fix/tiktok-status-fail-reason branch from 9290395 to ce3c2e6 Compare August 12, 2026 11:56
@giladresisi giladresisi changed the title chore(tiktok): log the status response while a post is still in progress chore(tiktok): log fail_reason when a post stays in progress Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant