{"record":{"id":"c39852a70f9b708f","repo":"gitroomhq/postiz-app","slug":"x-created-the-article-draft-but-could-not-publish","errorCode":null,"errorMessage":"X created the article draft but could not publish it, check your drafts on X","messagePattern":"X created the article draft but could not publish it, check your drafts on X","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/x.provider.ts","lineNumber":1157,"sourceCode":"          accessSecretSplit\n        ),\n        'Content-Type': 'application/json',\n      },\n    });\n    const publishJson = (await publishResponse.json()) as {\n      data?: { post_id: string };\n      errors?: any[];\n    };\n\n    if (publishJson?.errors?.length) {\n      console.log(\n        'X article publish returned errors:',\n        JSON.stringify(publishJson.errors)\n      );\n    }\n\n    if (!publishJson?.data?.post_id) {\n      throw new BadBody(\n        this.identifier,\n        JSON.stringify(publishJson),\n        Buffer.from('{}'),\n        'X created the article draft but could not publish it, check your drafts on X'\n      );\n    }\n\n    return {\n      status: 'completed',\n      postId: publishJson.data.post_id,\n      releaseURL: `https://twitter.com/${integration.profile}/status/${publishJson.data.post_id}`,\n    };\n  }\n\n  override async finalizePost(\n    accessToken: string,\n    pendingData: XPendingData,\n    integration: Integration","sourceCodeStart":1139,"sourceCodeEnd":1175,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/x.provider.ts#L1139-L1175","documentation":"The X article draft was created (draftJson.data.id exists) but the subsequent publish call returned no data.post_id, so the article exists only as a draft on X. The error tells the user to check their drafts on X rather than silently failing.","triggerScenarios":"Publish endpoint returns errors (validation on publish, permission to publish articles missing, rate limit) or an envelope lacking post_id even though the draft step succeeded.","commonSituations":"Account can draft but not auto-publish articles (feature gating); X changed the publish response shape; publish called with a malformed draft id.","solutions":["Open X and check the account's drafts — the article text is likely there; publish or fix it manually","Inspect publishJson in the error body for the specific errors array","Verify the account has permission to publish articles programmatically","Retry the post once to rule out transient publish errors"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"const hasPublishedPostId = (j: unknown): j is { data: { post_id: string } } => Boolean((j as any)?.data?.post_id);","tryCatchPattern":"catch (e) { if (e instanceof BadBody && e.message.includes('could not publish it')) { /* notify user draft exists on X; offer manual publish */ } throw e; }","preventionTips":["Warn users their draft may exist on X when publish fails","Check publishJson.errors for actionable permission issues","Keep draft fallback UX so content is never lost"],"tags":["x-twitter","articles","publish-failed","draft"],"backgroundTag":"social-media-publish-failed","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}