jackwener/OpenCLI · error · CommandExecutionError
Instagram private publish failed to ${stage}
Error message
Instagram private publish failed to ${stage} What it means
Generic wrapper for failures of the macOS `swift` helper script used by the private publish pipeline (reading video metadata, generating cover images, trimming story video). When the spawned swift process errors or exits non-zero, this error is thrown with the process output as detail.
Source
Thrown at clis/instagram/_shared/private-publish.js:412
}
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(' ');
throw new CommandExecutionError(`Instagram private publish failed to ${stage}`, detail || 'swift helper failed');
}
return JSON.parse(String(result.stdout || '{}'));
}
catch (error) {
if (error instanceof CommandExecutionError)
throw error;
throw new CommandExecutionError(`Instagram private publish failed to ${stage}`, error instanceof Error ? error.message : String(error));
}
finally {
fs.rmSync(scriptPath, { force: true });
}
}
function readVideoMetadata(filePath) {
if (process.platform !== 'darwin') {
throw new CommandExecutionError(`Instagram private mixed-media publish does not support reading video metadata on ${process.platform}`, 'Use macOS for private mixed-media publishing, or rely on the UI fallback');
}
const metadata = runSwiftJsonScript(`
import AVFoundationView on GitHub (pinned to 49907e53dc)
Solutions
- Read the detail (swift stderr/stdout) for the exact failure
- Install/repair the Xcode command line tools so `swift` runs (`xcode-select --install`)
- Verify the input video path exists and is a playable mp4/mov
- Pre-trim or pre-generate covers with ffmpeg and skip the swift helper step
Example fix
// before
await publish({ media: 'clip.mp4' }); // swift helper fails
// after
// $ xcode-select --install # ensure swift toolchain
// or pre-process: $ ffmpeg -i clip.mp4 -t 15 clip-trimmed.mp4
await publish({ media: 'clip-trimmed.mp4' }); Defensive patterns
Strategy: try-catch
Validate before calling
const probe = spawnSync('swift', ['--version']);
if (probe.error || probe.status !== 0) throw new Error('swift toolchain unavailable');
if (!fs.existsSync(videoPath)) throw new Error(`missing video: ${videoPath}`); Try / catch
try {
await publish(cfg);
} catch (e) {
if (/private publish failed to .+/.test(e.message)) {
// inspect e.detail for swift stderr; install CLT or pre-process with ffmpeg
} else throw e;
} Prevention
- Install Xcode command line tools (`xcode-select --install`) on the macOS host
- Validate video files exist and are playable before publish
- Pre-trim videos / generate covers with ffmpeg to avoid the swift path
- Keep the swift toolchain updated with macOS releases
When it happens
Trigger: runSwiftJsonScript spawns a swift helper and result.error is set or result.status !== 0, during metadata extraction, cover image generation, or story video trimming.
Common situations: macOS host without a working swift toolchain (no Xcode command line tools), missing input video file, unsupported codec, timeout/OOM on large videos.
Related errors
- Instagram private publish failed to normalize ${asset.fileNa
- Instagram private story publish failed to normalize ${asset.
- ChatGPT Desktop integration requires macOS (osascript is not
- ChatGPT Desktop integration requires macOS (osascript is not
- ChatGPT Desktop integration requires macOS (osascript is not
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b93fc8eea1486bac.
Report an issue: GitHub.