gitroomhq/postiz-app · error · BadBody

The file is corrupted and cannot be uploaded

Error message

The file is corrupted and cannot be uploaded

What it means

While polling Pinterest's media file status during checkPostStatus, the uploaded file reached status='failed', meaning Pinterest rejected/could not process the file. The pin will never be created from this file.

Source

Thrown at libraries/nestjs-libraries/src/integrations/social/pinterest.provider.ts:401

          },
          '',
          0,
          true
        )
      ).json();
    } catch (err) {
      if (err instanceof RefreshToken) {
        throw err;
      }

      // Transient status-check error: the media may finish processing just
      // fine, keep polling - if Pinterest stays broken the workflow exhausts
      // its checks and warns the user properly.
      return { status: 'pending', pendingData };
    }

    if (mediafile.status === 'failed') {
      throw new BadBody(
        'pinterest',
        JSON.stringify({}),
        {} as any,
        'The file is corrupted and cannot be uploaded'
      );
    }

    if (mediafile.status !== 'succeeded') {
      return { status: 'pending', pendingData };
    }

    return witness();
  }

  override async finalizePost(
    accessToken: string,
    pendingData: PinterestPendingData,
    integration: Integration

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Re-upload the original file (verify it opens locally)
  2. Convert the image to a standard RGB JPEG/PNG within Pinterest size limits
  3. Re-attach the media and retry the post

Example fix

// before
uploadMedia('photo.cmyk.jpg');
// after
uploadMedia('photo.rgb.jpg'); // convert to sRGB JPEG before upload
Defensive patterns

Strategy: validation

Validate before calling

const img = await sharp(file).metadata(); // throws on corrupt input
if (!['jpeg','png','webp'].includes(img.format)) throw new Error('Unsupported format');

Prevention

When it happens

Trigger: Polling the Pinterest media upload returns status 'failed' — corrupt image, unsupported format, or Pinterest-side processing error.

Common situations: Corrupt or truncated uploads, CMYK/exotic image formats, files that fail Pinterest's validation, interrupted upload producing a broken file.

Related errors


AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27). Data as JSON: /api/errors/5b23c01087d4f046. Report an issue: GitHub.