jackwener/OpenCLI · warning

Midjourney CDN reported ${media.mime || 'unknown'} for ${url

Error message

Midjourney CDN reported ${media.mime || 'unknown'} for ${url}; detected ${actualMime} from file bytes

What it means

When downloading a raw Midjourney video, the CDN-reported Content-Type disagreed with the MP4 type detected from the file bytes. The bytes were validated as video/mp4 (otherwise it would throw), so this is only a warning before the buffer is written to disk.

Source

Thrown at clis/midjourney/utils.js:723

  } catch (error) {
    await fs.unlink(tempPath).catch(() => {});
    throw new CommandExecutionError(`Could not write Midjourney media ${filePath}: ${errorMessage(error)}`);
  }
}

export async function downloadRawVideo(page, jobId, index, outputDir, force = false) {
  await fs.mkdir(outputDir, { recursive: true });
  const url = rawVideoUrl(jobId, index);
  const filePath = path.join(outputDir, `${jobId}_${index + 1}_raw.mp4`);
  const existing = await existingMedia(filePath, force, 'video/mp4');
  if (existing) return { index, kind: 'video-raw', filePath, bytes: existing.size, url, mime: 'video/mp4', cached: true };
  const media = await fetchMediaThroughPage(page, url, 'video/');
  const actualMime = sniffMediaMime(media.buffer);
  if (actualMime !== 'video/mp4') {
    throw new CommandExecutionError(`Midjourney raw video returned invalid MP4 bytes from ${url}`);
  }
  if (media.mime !== actualMime) {
    log.warn(`Midjourney CDN reported ${media.mime || 'unknown'} for ${url}; detected ${actualMime} from file bytes`);
  }
  await writeMediaBuffer(filePath, media.buffer);
  return { index, kind: 'video-raw', filePath, bytes: media.buffer.length, url, mime: actualMime, cached: false };
}

export async function downloadRenderedVideo(page, jobId, index, kind, outputDir, force = false) {
  const config = kind === 'video-social'
    ? { label: 'Download for Social', extension: '.mp4', mime: 'video/mp4' }
    : kind === 'gif'
      ? { label: 'Download as GIF', extension: '.gif', mime: 'image/gif' }
      : null;
  if (!config) throw new ArgumentError('Rendered video kind must be video-social or gif');
  await fs.mkdir(outputDir, { recursive: true });
  const filePath = path.join(outputDir, `${jobId}_${index + 1}_${kind.replace('video-', '')}${config.extension}`);
  const existing = await existingMedia(filePath, force, config.mime);
  if (existing) return { index, kind, filePath, bytes: existing.size, url: null, mime: config.mime, cached: true };

  await page.goto(jobUrl(jobId, index));

View on GitHub (pinned to 49907e53dc)

Solutions

  1. No action required if the saved .mp4 plays correctly — bytes were validated as MP4
  2. Verify the output file with a media probe (ffprobe) if in doubt
  3. Check for proxies altering response headers
  4. Report persistent mismatches for a specific URL/region to the library maintainers
Defensive patterns

Strategy: validation

Validate before calling

const actual = sniffMediaMime(buffer);
if (actual !== 'video/mp4') throw new Error(`Expected video/mp4, got ${actual}`);

Type guard

const isMp4 = (m) => m === 'video/mp4';

Try / catch

try {
  await downloadRawVideo(page, jobId, index);
} catch (err) {
  if (/invalid MP4 bytes/.test(err.message)) { /* retry or fetch alternate rendition */ }
}

Prevention

When it happens

Trigger: fetchMediaThroughPage retrieves a raw video URL and media.mime (response header) differs from sniffMediaMime(buffer) which returned video/mp4.

Common situations: CDN serving videos with application/octet-stream or wrong Content-Type, browser-bridge page fetch reporting a generic MIME, CDN transcode/edge-cache misconfiguration.

Related errors


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