fix(tiktok): default content_posting_method to DIRECT_POST#1687
fix(tiktok): default content_posting_method to DIRECT_POST#1687giladresisi wants to merge 2 commits into
Conversation
The agent (chat / MCP) had to pick content_posting_method with no guidance: the setting is a bare required enum with no description or default, and TikTok's agent rules said nothing about it. For a video post "UPLOAD" reads like the obvious choice - but UPLOAD does not publish, it only drops the video into the user's TikTok app inbox, where it must be completed manually within ~24h or it is discarded. Users hit this as "post marked successful but never published". Two layers: - TikTok @rules text now tells the agent to use DIRECT_POST unless the user explicitly asks to review/edit in the app first, and explains that UPLOAD does not publish. - A PROVIDER_SETTINGS_DEFAULTS map + buildSettings() helper fills content_posting_method with DIRECT_POST when the key is omitted, in both validation and creation, so an omitted value can never land on UPLOAD by accident. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Contribution-checker quality warning Heuristics that flagged:
If this is a genuine contribution, please add detail to your PR description and tighten the diff scope before reviewers look at it. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
`content_posting_method` was exposed to schema consumers as a bare
`enum: ["DIRECT_POST", "UPLOAD"]` with no description, so an LLM asked to
"upload this video to TikTok" would reasonably pick the value literally
named UPLOAD - which never publishes, it only drops the media into the
user's TikTok app inbox where it expires after 24 hours.
Annotate the field with `@JSONSchema({ description })`. This is metadata
only: it is read by class-validator-jsonschema when generating the schema
and registers no validator, so `@IsIn([...])` still rejects a missing or
invalid value and the field stays required. Verified against the
generated schema: `description` is present, `enum` is unchanged, and
`content_posting_method` remains in `required`.
The annotation reaches every `getValidationSchemas()` consumer:
- `integrationSchema` MCP tool (internal web agent + external MCP agents)
- `GET /public/v1/integration-settings/:id` (public API, and the CLI's
`postiz integrations:settings`)
The dashboard is unaffected - its React form hardcodes DIRECT_POST.
For agents this layers on top of the @rules text in the previous commit:
the settings default only fills an omitted key, and since the field is
required an agent nearly always sends *something*, so the prose rule and
this description are what steer it away from UPLOAD. For public API
callers that read the schema but not `rules`, this is the only in-band
signal.
Precedent for the decorator: whop.dto.ts, discord.dto.ts, listmonk.dto.ts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This comment was marked as duplicate.
This comment was marked as duplicate.
|
Superseded by #1710. Same fix, cleaner history. The Closing in favour of #1710 — force-push is blocked on this branch, so the rewritten history could not be pushed here. |
Problem
Scheduled TikTok posts were being marked successful in Postiz and Temporal but never published. The
postSocialactivity returnedpostId: "missing"with atiktok.com/messagesrelease URL.Root cause: the post had
content_posting_method: "UPLOAD"instead ofDIRECT_POST.UPLOADdoes not publish — TikTok's API delivers the video to the account's app inbox, where the user must manually complete it within ~24h or it's discarded. This is TikTok'sSEND_TO_USER_INBOXterminal status, which we (correctly) treat as a successful upload.Why the agent chose
UPLOAD: the chat/MCP agent had to supplycontent_posting_methodwith no guidance — it's a bare required enum ('DIRECT_POST' | 'UPLOAD') with no description or default, and TikTok's agent@Rulessaid nothing about it. For a video post, "UPLOAD" reads like the obvious choice. The user never asked for it; the model guessed.Fix (three layers)
@Rulesguidance (tiktok.provider.ts): the agent is now told to useDIRECT_POSTunless the user explicitly asks to review/edit inside the TikTok app first, and thatUPLOADdoes not publish.integration.schedule.post.ts): aPROVIDER_SETTINGS_DEFAULTSmap +buildSettings()helper fillscontent_posting_methodwithDIRECT_POSTwhen the key is omitted — applied in both the validation and creation paths — so an omitted value can never land onUPLOADby accident. The default map is TikTok-only; all other providers reduce to the exact prior behavior.tiktok.dto.ts):@JSONSchema({ description })explains, on the field itself, thatUPLOADnever publishes.Why all three
They cover different populations, and the layers are not redundant:
@Rules(viaintegrationSchema), plus the default as a backstoprulesfromGET /public/v1/integration-settings/:id@Rules@JSONSchemadescriptionNote the default only fills a key that is
undefined/''. Because the field is required, an agent nearly always sends something — so the prose rule and the field description are what actually steer it away fromUPLOAD; the default is insurance against omission.The
@JSONSchemadecorator is metadata only — it registers no validator, so@IsIn([...])still rejects a missing or invalid value and the field remains required. The dashboard is unaffected: its React form hardcodesDIRECT_POST.Testing
content_posting_methodnow yieldsDIRECT_POST.TikTokDto:descriptionpresent,enumunchanged,content_posting_methodstill listed inrequired.tiktokentry).Not covered here
Two other copies of this enum are documented outside this repo and are unreachable from a backend change. Both are being fixed separately:
gitroomhq/postiz-docs—public-api/providers/tiktok.mdxdescribesUPLOADas "Upload for manual posting";public-api/openapi.jsonhas a bare enum with no description. (Hand-maintained, not generated.)gitroomhq/postiz-agent— the skill bundles its ownPROVIDER_SETTINGS.md, which lists the enum with no explanation. Skill runs read that file rather than callingintegrations:settings, so no backend fix reaches them.Notes
First of two related changes. A follow-up feature branch (agent list/update of scheduled posts) stacks on this one and will be opened as a separate PR.
🤖 Generated with Claude Code