jackwener/OpenCLI · error · CommandExecutionError

Instagram private publish failed to normalize ${asset.fileNa

Error message

Instagram private publish failed to normalize ${asset.fileName}

What it means

After spawning `sips --padToHeightWidth` on macOS to pad a feed image, the CLI checks for spawn errors, non-zero exit status, and existence of the output file; any of these failing raises this error with the collected stderr/stdout detail.

Source

Thrown at clis/instagram/_shared/private-publish.js:359

    const outputPath = buildPrivateNormalizedImagePath(filePath);
    const result = spawnSync('sips', [
        '--padToHeightWidth',
        String(normalizedDimensions.height),
        String(normalizedDimensions.width),
        '--padColor',
        INSTAGRAM_PRIVATE_PAD_COLOR,
        filePath,
        '--out',
        outputPath,
    ], {
        encoding: 'utf8',
    });
    if (result.error || result.status !== 0 || !fs.existsSync(outputPath)) {
        const detail = [result.error?.message, result.stderr, result.stdout]
            .map((value) => String(value || '').trim())
            .filter(Boolean)
            .join(' ');
        throw new CommandExecutionError(`Instagram private publish failed to normalize ${asset.fileName}`, detail || 'sips padToHeightWidth failed');
    }
    return {
        ...readImageAsset(outputPath),
        cleanupPath: outputPath,
    };
}
export function prepareImageAssetForPrivateStoryUpload(filePath) {
    const asset = readImageAsset(filePath);
    const normalizedDimensions = getInstagramStoryNormalizedDimensions(asset.width, asset.height);
    if (!normalizedDimensions) {
        return asset;
    }
    if (process.platform !== 'darwin') {
        throw new CommandExecutionError(`Instagram private story publish does not support auto-normalizing ${asset.fileName} on ${process.platform}`, `Use images within ${INSTAGRAM_MIN_STORY_ASPECT_RATIO.toFixed(2)}-${INSTAGRAM_MAX_STORY_ASPECT_RATIO.toFixed(2)} aspect ratio, or use the UI route`);
    }
    const outputPath = buildPrivateNormalizedImagePath(filePath);
    const result = spawnSync('sips', [
        '--padToHeightWidth',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the error detail (stderr/stdout appended as the second message) for the specific sips failure
  2. Verify `sips --padToHeightWidth 1350 1080 input.png --out output.png` works manually
  3. Check disk space and write permissions in the temp/output directory
  4. Normalize the image beforehand with another tool and skip auto-normalization

Example fix

// before
await publish({ media: 'broken.png' });
// after
// fix the image first:
// $ magick broken.png -background white -gravity center -extent 1080x1350 fixed.png
await publish({ media: 'fixed.png' });
Defensive patterns

Strategy: fallback

Validate before calling

// verify sips works before relying on auto-normalization
const probe = spawnSync('sips', ['--version']);
if (probe.error || probe.status !== 0) throw new Error('sips unavailable');

Try / catch

try {
  await publish(cfg);
} catch (e) {
  if (/failed to normalize/.test(e.message)) {
    cfg.media = normalizeWithImageMagick(cfg.media); // fallback tool, retry
  } else throw e;
}

Prevention

When it happens

Trigger: prepareImageAssetForPrivateUpload runs sips and result.error is set, result.status !== 0, or the normalized output file does not exist afterwards.

Common situations: sips missing or broken on the macOS host, unreadable/corrupt source image, disk full or permission-denied output path, sips cannot handle very large images.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/6e97b9ddd4d91e41. Report an issue: GitHub.