{"record":{"id":"acdcbf6470b4a060","repo":"jackwener/OpenCLI","slug":"instagram-private-story-publish-failed-to-normaliz","errorCode":null,"errorMessage":"Instagram private story publish failed to normalize ${asset.fileName}","messagePattern":"Instagram private story publish failed to normalize (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":393,"sourceCode":"    const outputPath = buildPrivateNormalizedImagePath(filePath);\n    const result = spawnSync('sips', [\n        '--padToHeightWidth',\n        String(normalizedDimensions.height),\n        String(normalizedDimensions.width),\n        '--padColor',\n        INSTAGRAM_PRIVATE_PAD_COLOR,\n        filePath,\n        '--out',\n        outputPath,\n    ], {\n        encoding: 'utf8',\n    });\n    if (result.error || result.status !== 0 || !fs.existsSync(outputPath)) {\n        const detail = [result.error?.message, result.stderr, result.stdout]\n            .map((value) => String(value || '').trim())\n            .filter(Boolean)\n            .join(' ');\n        throw new CommandExecutionError(`Instagram private story publish failed to normalize ${asset.fileName}`, detail || 'sips padToHeightWidth failed');\n    }\n    return {\n        ...readImageAsset(outputPath),\n        cleanupPath: outputPath,\n    };\n}\nfunction runSwiftJsonScript(script, args, stage) {\n    const scriptPath = path.join(os.tmpdir(), `opencli-instagram-${crypto.randomUUID()}.swift`);\n    fs.writeFileSync(scriptPath, script);\n    try {\n        const result = spawnSync('swift', [scriptPath, ...args], {\n            encoding: 'utf8',\n        });\n        if (result.error || result.status !== 0) {\n            const detail = [result.error?.message, result.stderr, result.stdout]\n                .map((value) => String(value || '').trim())\n                .filter(Boolean)\n                .join(' ');","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L375-L411","documentation":"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.","triggerScenarios":"prepareImageAssetForPrivateStoryUpload runs sips and result.error is set, result.status !== 0, or the output file is missing.","commonSituations":"Broken sips install, corrupt/unreadable source image, permission or disk-space problems writing the normalized file, unsupported color profile crashing sips.","solutions":["Inspect the detail message (sips stderr/stdout) for the root cause","Run the sips padToHeightWidth command manually to reproduce","Check disk space and output-directory permissions","Normalize the image externally (ImageMagick/sharp) so auto-normalization is skipped"],"exampleFix":"// before\nawait publishStory({ media: 'corrupt.png' });\n// after\n// re-encode externally:\n// $ magick corrupt.png -background black -gravity center -extent 1080x1920 ok.png\nawait publishStory({ media: 'ok.png' });","handlingStrategy":"fallback","validationCode":"const probe = spawnSync('sips', ['--version']);\nif (probe.error || probe.status !== 0) throw new Error('sips unavailable for story normalization');","typeGuard":null,"tryCatchPattern":"try {\n  await publishStory(cfg);\n} catch (e) {\n  if (/story publish failed to normalize/.test(e.message)) {\n    cfg.media = normalizeWithImageMagick(cfg.media); // fallback, retry\n  } else throw e;\n}","preventionTips":["Sanity-check sips on the host before story batches","Re-encode questionable images before upload","Monitor disk space where normalized outputs are written","Read the sips stderr detail appended to the error message"],"tags":["instagram","story","macos","sips","process"],"backgroundTag":"image-normalization-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}