jackwener/OpenCLI · error · CommandExecutionError

Instagram private story publish failed to normalize ${asset.

Error message

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

What it means

After spawning `sips --padToHeightWidth` to pad a story image on macOS, the CLI verifies spawn success, exit status 0, and existence of the normalized output file; any failure raises this error with joined stderr/stdout as detail.

Source

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

    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 story publish failed to normalize ${asset.fileName}`, detail || 'sips padToHeightWidth failed');
    }
    return {
        ...readImageAsset(outputPath),
        cleanupPath: outputPath,
    };
}
function runSwiftJsonScript(script, args, stage) {
    const scriptPath = path.join(os.tmpdir(), `opencli-instagram-${crypto.randomUUID()}.swift`);
    fs.writeFileSync(scriptPath, script);
    try {
        const result = spawnSync('swift', [scriptPath, ...args], {
            encoding: 'utf8',
        });
        if (result.error || result.status !== 0) {
            const detail = [result.error?.message, result.stderr, result.stdout]
                .map((value) => String(value || '').trim())
                .filter(Boolean)
                .join(' ');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Inspect the detail message (sips stderr/stdout) for the root cause
  2. Run the sips padToHeightWidth command manually to reproduce
  3. Check disk space and output-directory permissions
  4. Normalize the image externally (ImageMagick/sharp) so auto-normalization is skipped

Example fix

// before
await publishStory({ media: 'corrupt.png' });
// after
// re-encode externally:
// $ magick corrupt.png -background black -gravity center -extent 1080x1920 ok.png
await publishStory({ media: 'ok.png' });
Defensive patterns

Strategy: fallback

Validate before calling

const probe = spawnSync('sips', ['--version']);
if (probe.error || probe.status !== 0) throw new Error('sips unavailable for story normalization');

Try / catch

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

Prevention

When it happens

Trigger: prepareImageAssetForPrivateStoryUpload runs sips and result.error is set, result.status !== 0, or the output file is missing.

Common situations: Broken sips install, corrupt/unreadable source image, permission or disk-space problems writing the normalized file, unsupported color profile crashing sips.

Related errors


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