{"record":{"id":"d3082f948e294f8a","repo":"gitroomhq/postiz-app","slug":"handleerror-value-d3082f","errorCode":null,"errorMessage":"handleError.value","messagePattern":"handleError\\.value","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/x.provider.ts","lineNumber":863,"sourceCode":"      let processing:\n        | { state: string; check_after_secs?: number; error?: { message?: string } }\n        | undefined;\n      try {\n        processing = await this.mediaProcessingStatus(client, mediaId);\n      } catch (err: any) {\n        // twitter-api-v2 throws ApiResponseError, which never passes through\n        // this.fetch/handleErrors: classify it here so revoked tokens and\n        // suspended accounts fail properly instead of burning the whole check\n        // budget as \"transient\".\n        const body = JSON.stringify(err?.data || {});\n        const handleError = this.handleErrors(body);\n\n        if (err?.code === 401 || handleError?.type === 'refresh-token') {\n          throw new RefreshToken(this.identifier, body, Buffer.from('{}'));\n        }\n\n        if (handleError?.type === 'bad-body') {\n          throw new BadBody(\n            this.identifier,\n            body,\n            Buffer.from('{}'),\n            handleError.value\n          );\n        }\n\n        // Transient status-check error: the media may finish transcoding just\n        // fine, keep polling - if X stays broken the workflow exhausts its\n        // checks and warns the user properly.\n        return { status: 'pending', pendingData };\n      }\n\n      if (processing?.state === 'failed') {\n        throw new BadBody(\n          this.identifier,\n          JSON.stringify(processing),\n          Buffer.from('{}'),","sourceCodeStart":845,"sourceCodeEnd":881,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/x.provider.ts#L845-L881","documentation":"In checkPostStatus, when X is asked about a pending tweet, a bad-body type error from handleErrors causes rethrowing the provider error with handleError.value as the user-facing message. It reflects X's own API error body for the status/create call.","triggerScenarios":"The status-check request to X returns an error body that handleErrors classifies as 'bad-body' (non-auth error such as invalid request, duplicate content, over limit), so the original error is re-raised as BadBody with X's message.","commonSituations":"Posting duplicate content X rejects; exceeding rate/token limits mid-post; malformed status parameters for the pending post.","solutions":["Read handleError.value / the raw body attached to the BadBody — it is X's actual error message","Address the specific X error (e.g. duplicate status text, rate limit) and retry","If it is a refresh-token type error instead, the provider throws RefreshToken and the channel needs reconnecting","Retry after limits reset if the message indicates rate limiting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isBadBodyError = (e: unknown): e is BadBody => e instanceof BadBody;","tryCatchPattern":"catch (e) { if (e instanceof BadBody && e.identifier === 'x') { const msg = e.message; /* surface X's message; handle duplicate/limit cases specially */ } throw e; }","preventionTips":["Read the provider error body first — it carries X's real API message","Handle duplicates and rate limits distinctly before retrying","Keep posts within X rate limits per account/app"],"tags":["x-twitter","api-error","bad-body","status-check"],"backgroundTag":"social-media-api-error","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}